<template>
  <div class="main">
    <div class="page">
      <div class="main-container">
        <div class="left">
          <el-form ref="dataForm" class="form" :model="temp" label-position="right" label-width="90px">
            <el-form-item style="width: 200%;" label="电话号码:" prop="orderCode">
              <el-input v-model.trim="serach_phone" maxlength="11" style="width: 185px;" placeholder="请输入" @keyup.enter.native="searchForPhone" />
              <el-button type="primary" icon="el-icon-search" :loading="$loadingPlugin.searchForPhone" @click="searchForPhone">查询</el-button>
              <el-link v-show="temp.csmId" style="float: right;" :underline="false" size="mini" type="primary" @click="openUserDetail()">
                客户详情
              </el-link>
            </el-form-item>
            <el-card class="client-box" shadow="never">
              <div slot="header">
                <span>客户信息</span>
              </div>
              <div class="client-content">
                <div class="client-row">
                  <div class="client-label">客户编号：</div>
                  <div class="client-value" :title="temp.csmCode">{{ temp.csmCode }}</div>
                </div>
                <div class="client-row">
                  <div class="client-label">客户名称:</div>
                  <div class="client-value" :title="temp.csmName">{{ temp.csmName }}</div>
                </div>
                <div class="client-row">
                  <div class="client-label">客户类型:</div>
                  <div class="client-value" :title="temp.csmType">{{ temp.csmType ? temp.csmType == 1 ? "居民" : temp.csmType === 2 ? "商业" : "" : "" }}</div>
                </div>
                <div class="client-row">
                  <div class="client-label">一户一码：</div>
                  <div class="client-value" :title="temp.qrCode">{{ temp.qrCode }}</div>
                </div>
                <div class="client-row2">
                  <div class="client-label">身份证号：</div>
                  <div class="client-value" :title="temp.sfzh">{{ temp.sfzh }}</div>
                </div>
                <div v-if="temp.openAccountPhone" class="client-row">
                  <div class="client-label">开户电话：</div>
                  <div class="client-value" :title="temp.openAccountPhone">{{ temp.openAccountPhone }}</div>
                </div>
                <div v-if="addressRows.preferentialPackageId" class="client-row">
                  <div class="client-label2">剩余优惠瓶数：</div>
                  <div :class="addressRows.preferentialCount ? 'client-value link' : 'client-value red'" @click="showPreferentialDialog">{{ addressRows.preferentialCount }}</div>
                </div>
                <!-- <div class="client-row">
                  <div class="client-label">绑定司机：</div>
                  <div class="client-value" :title="temp.sfzh">{{ temp.sfzh }}</div>
                </div>
                <div class="client-row">
                  <div class="client-label">值班人：</div>
                  <div class="client-value" :title="temp.sfzh">{{ temp.sfzh }}</div>
                </div> -->
              </div>
              <div v-if="recheckbill">
                <div class="client-value red">该用户存在隐患尚未整改,请立即复检核查，目前无法购气</div>
              </div>
            </el-card>
            <!-- <el-form-item style="" label="客户编号:" prop="csmCode">
              <el-input v-model="temp.csmCode" style="width: 100%;" :disabled="csmcodeFlag" />
            </el-form-item>
            <el-form-item label="客户名称:" prop="csmName">
              <el-input v-model="temp.csmName" style="width: 100%;" placeholder="请输入" @blur="contactBlur" />
            </el-form-item>
            <el-form-item label="客户类型:" prop="csmType">
              <el-select v-model="temp.csmType" style="width: 100%;" placeholder="请选择">
                <el-option v-for="(l,i) in userType" :key="i" :value="l.value" :label="l.desc" />
              </el-select>
            </el-form-item>
            <el-form-item label="一户一码:" prop="csmCode">
              <el-input v-model="temp.qrCode" style="width: 100%;" :disabled="temp.qrCode?true:false" />
            </el-form-item> -->
          </el-form>
          <div ref="cardRef" class="cardBox_phone" style="display: flex; margin-bottom: 10px;">
            <el-card class="box-card" shadow="never" style="width: 40%; margin-right: 10px;">
              <div slot="header" class="clearfix">
                <span>关联电话</span>
              </div>
              <div v-if="phoneItems.length" style="height: 95px; overflow: auto;">
                <div ref="selectPhone">
                  <span v-for="(l,i) in phoneItems" :key="i" style="cursor: pointer;" class="text item" @click="selectPhone(i,l)">
                    <div>
                      <span style="margin-right: 5px;">{{ l.csmPhone }}</span>
                      <span>{{ l.contact }}</span>
                    </div>
                    <span v-if="i!==selectPhoneIndex">   <i class="el-icon-close" style="color: red;" @click.stop="delPhone(l,i)" />&nbsp;&nbsp;</span>
                  </span>
                </div>
              </div>
              <div v-else class="boxSky">暂无数据</div>
            </el-card>
            <el-card shadow="never" class="box-card border" style="width: 60%;">
              <div slot="header" class="clearfix">
                <span>关联地址</span>
              </div>
              <div v-if="addressItems.length" style="height: 95px; overflow: auto;">
                <div v-loading="$loadingPlugin.selectAddress">
                  <ul ref="selectAddress">
                    <li v-for="(l,i) in addressItems" :key="i" style="cursor: pointer;" class="text item" @click="selectAddress(i,l)">
                      <div>
                        <span>{{ l.csmAddress }}</span>
                      </div>
                      <span v-if="l.sp1 !== 2"><i class="el-icon-close" style="color: red;" @click.stop="delAddress(l,i)" /> &nbsp;&nbsp;</span>
                    </li>
                  </ul>
                </div>
              </div>
              <div v-else class="boxSky">暂无数据</div>
            </el-card>
          </div>
          <el-form ref="dataForm" class="form" :model="temp" label-position="right" label-width="90px">
            <!-- <div class="moneyinfo">
              <div class="moneyinfo-item"><span>最近订气:</span><span class="moneyinfo-value">{{ phoneData.lastBuyDt&&new Date(phoneData.lastBuyDt).getFullYear()*1!=='1990'*1?dayjs(phoneData.lastBuyDt).format('YY-MM-DD'):'' }}</span></div>
              <div class="moneyinfo-item"><span>开户日期:</span><span class="moneyinfo-value">{{ phoneData.createTime&&dayjs(phoneData.createTime).format('YY-MM-DD') }}</span></div>
              <div class="moneyinfo-item"><span>余额:</span><span class="moneyinfo-value">{{ cmsCodeData.cardSurplus?cmsCodeData.cardSurplus/100:"" }}</span></div>
              <div class="moneyinfo-item"><span>积分:</span><span class="moneyinfo-value">{{ temp.score }}</span></div>
              <div class="moneyinfo-item"><span>押金:</span><span class="moneyinfo-value">{{ temp.deposit?temp.deposit:'' }}<span v-show="phoneData.expirationDt&&moment(phoneData.expirationDt).diff(moment(new Date()), 'days') <= 90" style="color: red;">（押金即将到期）</span></span></div>
              <div class="moneyinfo-item2"><span>最近安检:</span><span ref="anjian" class="moneyinfo-value" v-html="checkDtStr" /></div>
            </div> -->
            <el-form-item :label="'电'+ '\u3000' + '\u3000' + '话:'" prop="contactPhone">
              <el-input v-model="contactInfo.csmPhone" style="width: 100%;" />
            </el-form-item>
            <el-form-item label="联系人:" prop="contact">
              <el-input v-model="contactInfo.contact" style="width: 100%;" placeholder="请输入" />
            </el-form-item>
            <el-form-item label="所属机构:" prop="orgName">
              <el-tree-select
                ref="a"
                :key="treeKey"
                v-model="AddressData.orgSNNo"
                :clearable="false"
                class="tree-select"
                :popover-width="360"
                :select-params="{
                  clearable: true,
                  placeholder: '请选择组织机构',
                  loading: $loadingPlugin.getTreeData
                }"
                :tree-params=" {
                  'default-expanded-keys':expandedList,
                  'node-key':'orgSNNo',
                  'default-expand-all': expandAll,
                  'expand-on-click-node': false,
                  'highlight-current': true,
                  props:{
                    value:'orgSNNo',
                    label: 'orgName',
                    disabled: 'disabled',
                  },
                  data: orgTreeDataReal
                }"
                @node-click="selectOrgTreeChange"
              />
            </el-form-item>
            <el-form-item v-if="cascaderSwitch" style="width: 33.3%;" label="所在区域:" prop="orderCode">
              <el-cascader ref="cascader" :key="cascaderKey" v-model="AddressData.address" style="width: 100%;" :props="addressProps" clearable @change="selectCascader" />
            </el-form-item>
            <el-form-item v-if="cascaderSwitch" style="width: 65.7%; margin-left: 1%;" label="" label-width="0" prop="orderCode">
              <el-autocomplete
                ref="suggestionInput"
                v-model="AddressData.csmAddress"
                v-scrollLoad="getLoad"
                style="width: 100%;"
                :maxlength="50"
                :debounce="300"
                popper-class="address-autocomplete"
                :fetch-suggestions="queryAddressSearch"
                placeholder="请输入详细地址"
                :trigger-on-focus="false"
                @select="handleSelect"
              >
                <template slot-scope="{ item }">
                  <div class="name">{{ item.value }}</div>
                  <span class="addr">{{ item.address }}</span>
                </template>
              </el-autocomplete>
              <!-- <el-input v-model="AddressData.csmAddress" maxlength="50" style="width: 100%;" placeholder="请输入详细地址" @change="selectAddressFlag?temp.csmId=null:''" /> -->
            </el-form-item>
            <el-form-item v-else style="width: 100%;" label="详细地址:" prop="orderCode">
              <el-autocomplete
                ref="suggestionInput"
                v-model="AddressData.csmAddress"
                v-scrollLoad="getLoad"
                style="width: 100%;"
                :maxlength="50"
                :debounce="300"
                popper-class="address-autocomplete"
                :fetch-suggestions="queryAddressSearch"
                placeholder="请输入详细地址"
                :trigger-on-focus="false"
                @select="handleSelect"
              >
                <template slot-scope="{ item }">
                  <div class="name">{{ item.value }}</div>
                  <span class="addr">{{ item.address }}</span>
                </template>
              </el-autocomplete>
              <!-- <el-input v-model="AddressData.csmAddress" maxlength="50" style="width: 100%;" placeholder="请输入详细地址" @change="selectAddressFlag?temp.csmId=null:''" /> -->
            </el-form-item>
            <el-form-item label="门牌号:" style="width: 53%;" prop="doorplate">
              <el-input v-model="AddressData.doorplate" style="width: 100%;" placeholder="请输入" />
            </el-form-item>
            <el-form-item style="width: 60px; margin-left: 5px;" label="" label-width="0" prop="csmFloor">
              <el-input v-model="AddressData.csmFloor" style="width: 100%;" placeholder="" @blur="changeFloor">
                <template slot="suffix">层</template>
              </el-input>
            </el-form-item>
            <el-button type="primary" style="width: 40px; height: 32px; margin-left: 5px;" icon="el-icon-location-information" size="mini" @click="location" />
            <!-- <el-form-item label="身份证号:" prop="sfzh">
              <el-input v-model="temp.sfzh" maxlength="18" style="width: 100%;" placeholder="请输入" />
            </el-form-item> -->
            <el-form-item v-if="businessLicense&&(temp.csmType===2||temp.csmType===4)" label=" 营业执照:" prop="">
              <el-input v-if="!cardList.length" v-model="temp.zzbh" placeholder="请输入营业执照" />
              <el-select
                v-else
                v-model="temp.zzbh"
                allow-create
                clearable
                default-first-option
                filterable
                placeholder="请选择"
                @change="WOStatusChange"
                @blur="zzbhBlur"
              >
                <el-option
                  v-for="(item,i) in cardList"
                  :key="i"
                  :label="item.text"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="销售员:" prop="saleMan">
              <el-input v-model="temp.saleMan" style="width: 100%;" placeholder="请输入" clearable disabled>
                <el-button v-if="!temp.saleMan" slot="append" class="append-search huoqu" plain @click="openInsure">查询</el-button>
                <el-button v-else slot="append" class="append-search huoqu" plain @click="temp.saleMan=''">清除</el-button>
              </el-input>
            </el-form-item> -->
            <div v-show="monthlyBillEndDt" style=" margin-left: 20px; font-size: 14px; line-height: 35px; color: red;">{{ monthlyBillTips1 }}</div>
            <el-form-item label-width="90px" label="客户备注:" prop="remark" style="width: 66.5%;" class="block">
              <el-input v-model="temp.remark" style="color: red;" type="textarea" :rows="2" maxlength="200" show-word-limit />
            </el-form-item>
            <el-form-item label-width="20px" label="" prop="remark" style="display: flex; align-items: center; width: 13%;">
              <el-checkbox v-model="isPickUp">自提客户</el-checkbox>
            </el-form-item>
            <el-form-item label-width="0" style="display: flex; width: 20%; flex-direction: row-reverse;">
              <el-button style="margin-top: 10px;" type="primary" icon="" @click="saveUser"><svg-icon icon-class="saveUser" /> 保存客户</el-button>
            </el-form-item>
          </el-form>
          <div class="order-container">
            <div class="order">
              <keep-alive>
                <div ref="orderRef" class="tabs_content" :class="TabsActiveName">
                  <el-tabs ref="elTabsRef" v-model="TabsActiveName" shadow="never" :tab-position="'left'" type="border-card" style="box-shadow: none;" @tab-click="handleClick">
                    <el-tab-pane label="订购" name="dingGou">
                      <div style="">
                        <el-form ref="form" size="mini" label-width="90px" class="orderForm" :model="orderForm">
                          <!-- <el-form-item style="width: 21%;" label="" prop="" label-width="0">
                            <el-radio-group v-model="orderForm.orderFlag" @change="changeRadioL">
                              <el-radio :label="1">购买</el-radio>
                              <el-radio :label="2">兑换</el-radio>
                            </el-radio-group>
                          </el-form-item> -->
                          <el-form-item style="width: 35%;" label="商品分类:" prop="orgSNNo">
                            <el-tree-select
                              :key="treeKey"
                              v-model="orderForm.gtId"
                              style="width: 100%;"
                              :disabled="isFirst"
                              :clearable="false"
                              class="tree-select"
                              :popover-width="300"
                              :select-params="{
                                clearable: true,
                                placeholder: '请选择商品分类',
                                loading: $loadingPlugin.getTreeData
                              }"
                              :tree-params=" {
                                'expand-on-click-node': false,
                                'highlight-current': true,
                                props:{
                                  value:'gtId',
                                  label: 'gtName',
                                  disabled: 'disabled',
                                },
                                data: goodsTreeDataDeatil
                              }"
                              @node-click="selectTreeChange"
                            />
                          </el-form-item>
                          <el-form-item v-show="!isFirst" style="width: 35%;" label="商品名称:">
                            <el-select v-model="orderForm.goodsId" style="width: 100%; margin-right: 2px;" @change="changeGoods">
                              <el-option v-for="(l,i) in goodsTypesDetailList" :key="i" :value="l.goodsId" :label="l.goodsName" />
                            </el-select>
                          </el-form-item>
                          <el-form-item style="display: flex; flex-direction: row-reverse; width: 20%;" label-width="20px">
                            <el-button v-show="!isFirst" type="primary" icon="el-icon-plus" :loading="btnStatus" :disabled="readOnly" @click="addGoods">添加</el-button>
                          </el-form-item>
                        </el-form>
                        <lb-table
                          v-show="orderForm.orderFlag===1"
                          ref="lbTable"
                          class="tableOrder"
                          :summary-method="getSummaries"
                          show-summary
                          highlight-current-row
                          max-height="400"
                          element-loading-text="加载中"
                          :column="tableData.column"
                          :data="tableData.data"
                          :pagination="false"
                        />
                        <lb-table
                          v-show="orderForm.orderFlag===2"
                          ref="lbTable1"
                          class="tableOrder"
                          :summary-method="getSummaries"
                          show-summary
                          highlight-current-row
                          max-height="400"
                          element-loading-text="加载中"
                          :column="tableDataScore.column"
                          :data="tableDataScore.data"
                          :pagination="false"
                        />
                        <div v-show="isShow && gdn" style="color: #f00;">友情提示：该用户之前订购过【{{ gdn }}】，已自动将该商品添加到订购列表</div>
                        <div style="  display: flex; margin-top: 10px; margin-bottom: 10px;">
                          <p style="width: max-content; font-size: 14px; color: #333; flex-shrink: 0;"> 订单备注: </p>
                          <span style="width: 10px; flex-shrink: 0;" />
                          <el-input v-model="submitForm.remark" type="textarea" :rows="2" maxlength="200" show-word-limit />
                        </div>
                      </div>
                    </el-tab-pane>
                    <el-tab-pane lazy label="退瓶" name="tuiPing">
                      <BottleReturn ref="tuiPing" :temp="temp" :address-data="AddressData" :submit-form="submitForm" />
                    </el-tab-pane>
                    <el-tab-pane lazy label="信息" name="xinXi">
                      <Message ref="xinXi" :deposit-order-data="depositOrderData" :open-flow="openFlow" :parse-time="parseTime" :open-urge="openUrge" :open-back-order="openBackOrder" />
                    </el-tab-pane>
                  </el-tabs>
                </div>
              </keep-alive>
            </div>
          </div>
        </div>
        <div class="right" :style="{ height }">
          <draggable animation="300" :move="getdata" style="height: 100%;" @update="datadragEnd">
            <transition-group style=" display: flex; height: 100%; flex-direction: column;">
              <!-- <el-card v-if="insureSeting" :key="0" :data-id="0" shadow="never" class="chit_card cardBox_phone cardone">
                <div slot="header" class="clearfix cup">
                  <span>保险信息</span>
                  <i style="float: right; padding: 3px 0;" class="el-icon-caret-bottom" @click="fold('car_main')" />
                </div>
                <div ref="car_main" class="card_main1">
                  <el-form ref="dataFormRight" class="dataFormRight" :model="temp" label-position="right" label-width="80px">
                    <el-form-item label="保险时间:" prop="insurance" style="margin-bottom: 10px;">
                      <el-date-picker
                        :key="temp.insureCodeFlag"
                        v-model="temp.insurance"
                        clearable
                        style="width: 100%;"
                        :style="{backgroundColor: isDaoqi() ? '#FF3366' : ''}"
                        type="daterange"
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期"
                        unlink-panels
                      />
                    </el-form-item>
                    <div style="display: flex; align-items: center;">
                      <el-form-item style="width: 60%; margin-bottom: 0;" label="保险单号:" prop="orderCode">
                        <el-input v-model="temp.insureCode" placeholder="请输入" :maxlength="20" :disabled="!insureCodeFlag" clearable @blur="changeInsureCode">
                          <el-button v-if="insureCodeFlag" slot="append" style="color: #01999f;" plain class="append-search huoqu" @click="getCmsCode(10)">获取</el-button>
                        </el-input>
                      </el-form-item>
                      <el-form-item label="售保人:" style="width: 40%; margin-bottom: 0;" prop="insuranceMan">
                        <el-input v-model="temp.insuranceMan" placeholder="请输入" disabled />
                      </el-form-item>
                    </div>
                  </el-form>
                </div>
              </el-card> -->
              <el-card :key="2" ref="cardIsH560" :data-id="2" shadow="never" class="chit_card cardBox_phone cardBox_shortcut cardthree" style="flex: 1; border: none;">
                <div slot="header" class="clearfix cup">
                  <span>快捷查询</span>
                  <i style="float: right; padding: 3px 0;" class="el-icon-caret-bottom" @click="fold('shortcut')" />
                </div>
                <div ref="shortcut" class="card_main_shortcut fastSearchstyle">
                  <div>
                    <el-form ref="shortcut" style="display: flex; flex-wrap: wrap;" class="form2" :model="shortcutParams" label-position="right" label-width="80px">
                      <el-form-item style="width: 100%; margin-bottom: 10px;" label="条件类型:" prop="csmPhone">
                        <div style="display: flex;">
                          <el-select slot="prepend" v-model="shortcutParams.select" style="width: 100px;" placeholder="请选择" @change="typeChange">
                            <el-radio-group v-model="radioChoose" @change="changRadio">
                              <el-option
                                v-for="item in optionsArr"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value"
                              >
                                <span style="float: left;">{{ item.label }}</span>
                                <span class="radio-choose">
                                  <el-radio :label="item.value">默认</el-radio>
                                </span>
                              </el-option>
                            </el-radio-group>
                            <!-- <el-option label="客户电话" :value="1" />
                            <el-option label="客户名称" :value="2" />
                            <el-option label="客户编码" :value="3" />
                            <el-option label="身份证" :value="4" />
                            <el-option label="使用证" :value="5" />
                            <el-option label="充值卡" :value="6" /> -->
                          </el-select>
                          <!-- <el-button slot="prepend" class="append-search" @click="saveDefault">保存</el-button> -->
                          <el-input v-model="shortcutParams.csmPhone" class="fast-checkinput" placeholder="请输入" clearable />
                        </div>

                      </el-form-item>
                      <el-form-item style="flex: 1; margin-bottom: 10px;" label="客户地址:" prop="cmsAddress">
                        <el-input v-model="shortcutParams.cmsAddress" placeholder="请输入" clearable />

                      </el-form-item>
                      <el-form-item style="min-width: 90px; flex-shrink: 0; margin-bottom: 10px;" label="" label-width="0">

                        <el-button style="width: 100%;" type="primary" icon="el-icon-search" @click="fastSearch(true)">快速查询</el-button>

                      </el-form-item>
                    </el-form>
                    <div class="fontItem">
                      结果信息栏 --仅显示前100条
                    </div>
                    <ul ref="checkRadio">
                      <li v-for="(l,i) in qkparams" :key="i" class="shortcut" style="margin: 5px 0;">
                        <el-radio v-model="radio1" class="shortcut_left" :label="i" @change="changeRadio" />
                        <div class="shortcut_right">
                          <div>{{ l.csmRgPhone }}({{ l.csmName }}) &nbsp; <span>编号:{{ l.csmCode }}</span> </div>
                          <div v-if="l.orgName" style="color: red;">{{ l.orgName ? l.orgName : '' }}</div>
                          <div> {{ l.csmRgAddress }}</div>
                        </div>
                      </li>
                    </ul>
                  </div>
                </div>
              </el-card>
              <el-card :key="1" :data-id="1" shadow="never" class="chit_card cardBox_phone cardBox_order cardtwo">
                <div slot="header" class="clearfix cup">
                  <span>最近三次订购记录</span>
                  <span class="midOrder">订气总数:{{ temp.totalGasCount }}</span>
                  <i style="float: right; padding: 3px 0;" class="el-icon-caret-bottom" @click="fold('order')" />
                </div>
                <div ref="order" class="card_main" :style="{padding:cmstop3.length ? '0 10px 10px 5px' : '0 10px 0px 5px'}">
                  <div style=" height: 100%;">

                    <el-table
                      :data="cmstop3"
                      height="150px"
                      header-row-class-name="tableHeader"
                      :header-row-style="{heigth:'25px',lineHeight:'25px',padding:0}"
                    >
                      <el-table-column
                        prop="orderCode"
                        label="订单号"
                        :show-overflow-tooltip="true"
                        width="110"
                      >
                        <template slot-scope="scope">
                          <el-link :underline="false" @click="openOrderDetail(scope.row)">
                            {{ scope.row.orderCode }}
                          </el-link>
                        </template>
                      </el-table-column>
                      <el-table-column
                        prop="goodsCount"
                        label="数量"
                        width="50"
                      />
                      <el-table-column
                        prop="goodsDesc"
                        label="商品描述"
                        :show-overflow-tooltip="true"
                        width="150"
                      />
                      <el-table-column
                        prop="transactTime"
                        label="下单时间"
                        width="140"
                      >
                        <template slot-scope="scope">
                          {{ scope.row.transactTime && parseTime(scope.row.transactTime, '{y}-{m}-{d} {h}:{i} ') }}
                        </template>
                      </el-table-column>
                      <el-table-column
                        prop="appointmentDt"
                        label="预约时间"
                        width="200"
                      >
                        <template slot-scope="scope">
                          {{ scope.row.appointmentDt && scope.row.dateTimeSpare1 ? parseTime(scope.row.dateTimeSpare1, '{h}:{i}') === '23:59' ? parseTime(scope.row.appointmentDt, '{y}-{m}-{d}') : parseTime(scope.row.appointmentDt, '{y}-{m}-{d} {h}:{i}') + ' 至 ' + parseTime(scope.row.dateTimeSpare1, '{h}:{i}') : '', }}
                        </template>
                      </el-table-column>
                      <el-table-column
                        prop="address"
                        label="来源"
                        width="80"
                      >
                        <template slot-scope="scope">
                          <span>{{ EnumList2.find(l => l.value === scope.row.fromPlat) ? EnumList2.find(l => l.value === scope.row.fromPlat).desc : '' }}</span>
                        </template>
                      </el-table-column>
                      <el-table-column
                        prop="address"
                        label="状态"
                        width="80"
                      >
                        <template slot-scope="scope">
                          <span>{{ EnumList1.find(l => l.value === scope.row.orderStatus) ?EnumList1.find(l => l.value === scope.row.orderStatus).desc : '' }}</span>
                        </template>
                      </el-table-column>
                      <el-table-column
                        prop="csmAddress"
                        label="客户地址"
                        :show-overflow-tooltip="true"
                        width="200"
                      />
                      <el-table-column
                        prop="orgName"
                        label="所属机构"
                        :show-overflow-tooltip="true"
                        width="150"
                      />
                      <el-table-column
                        prop="address"
                        label="操作"
                        align="center"
                        fixed="right"
                        width="90"
                      >
                        <template slot-scope="l">
                          <div style="display: flex;">
                            <el-link v-if="(l.row.orderStatus === 2 || l.row.orderStatus === 5)" :underline="false" size="mini" type="primary" @click="openUrge({ billCode: l.row.orderCode, billType: 1 })">
                              催单
                            </el-link>
                            <!-- <el-link v-if="(l.row.orderStatus === 2 || l.row.orderStatus === 5)" :underline="false" size="mini" type="primary" @click="openBackOrder(l.row)">
                              退单
                            </el-link> -->
                            <!-- <el-link :underline="false" size="mini" type="primary" @click="openFlow(l.row)">
                              流转
                            </el-link> -->
                            <el-link v-if="l.row.isReservation===1&&(l.row.orderStatus===2||l.row.orderStatus===1)" v-permission="1" :underline="false" size="mini" type="primary" @click="changeAppointmentDt(l.row)">
                              修改
                            </el-link>
                          </div>
                        </template>
                      </el-table-column>
                    </el-table>
                  </div>
                </div>
              </el-card>
            </transition-group>
          </draggable>
        </div>
      </div>
      <div v-show="TabsActiveName!=='xinXi'" class="footer-container">
        <div style="width: 88%;">
          <el-form ref="submitForm" class="footer_form" label-position="right" label-width="80px" size="mini" :model="submitForm">
            <el-form-item label="责任机构:" prop="orgName" style="margin-bottom: 10px;">
              <el-tree-select
                :key="treeKey"
                v-model="submitForm.orgSNNo"
                :disabled="isFirst&&TabsActiveName==='dingGou'"
                :clearable="false"
                class="tree-select"
                :popover-width="360"
                :select-params="{
                  clearable: true,
                  placeholder: '请选择组织机构',
                  loading: $loadingPlugin.getTreeData
                }"
                :tree-params=" {
                  'default-expanded-keys':expandedList,
                  'node-key':'orgSNNo',
                  'default-expand-all': expandAll,
                  'expand-on-click-node': false,
                  'highlight-current': true,
                  'filterable': true,
                  props:{
                    value:'orgSNNo',
                    label: 'orgName',
                    disabled: 'disabled',
                  },
                  data: orgTreeDataReal
                }"
                @node-click="SubmitSelectOrgTreeChange"
              />
            </el-form-item>
            <el-form-item label="处理人:" prop="address" style="margin-bottom: 10px;">
              <el-select v-model="submitForm.ownerId" placeholder="请选择" filterable>
                <el-option v-for="l in userData" :key="l.userId" :value="l.userId" :label="l.userName" />
              </el-select>
            </el-form-item>
            <!-- <el-form-item v-if="TabsActiveName!=='touSu'&& PageOpitonsFn('预约')" class="yuyueriqi" label="预约时间:" prop="appointment" style="margin-bottom: 10px;">
              <el-checkbox v-model="isTrue" @change="haveTime" />
              <el-date-picker
                v-model="submitForm.appointment"
                style="width: 75%; min-width: 90px;"
                type="date"
                placeholder="选择日期"
                :picker-options="pickerOptions0"
              />
            </el-form-item>
            <el-form-item v-if="TabsActiveName!=='touSu'&& PageOpitonsFn('预约')" class="yuyueshijian" label=" " label-width="0" prop="appointment" style="margin-bottom: 10px;">
              <el-row>
                <el-col :span="11">
                  <el-time-picker
                    v-model="time0"
                    style="width: 100%;"
                    format="HH:mm"
                    :picker-options="{
                      selectableRange:`${dayjs(new Date()).format('HH:mm:ss')} - 23:59:00`
                    }"
                    placeholder="开始时间"
                  />
                </el-col>
                <el-col :span="2">
                  &nbsp;至
                </el-col>
                <el-col :span="11">
                  <el-time-picker
                    v-model="time1"
                    style="width: 100%;"
                    format="HH:mm"
                    :picker-options="{
                      selectableRange:`${dayjs(new Date().getTime() + 3600000).format('HH:mm:ss')} - 23:59:00`
                    }"
                    placeholder="结束时间"
                  />
                </el-col>
              </el-row>
            </el-form-item> -->
            <el-form-item v-if="(appointmentInfo.sp1>>4 & 0x01)===1&&TabsActiveName==='dingGou'" label="预约时间：" label-width="90px">
              <div class="appointment">
                <div class="appointment-row">
                  <p class="timeContent" @click="showAppointment">
                    <span v-if="!currentDayContent" class="placeholder">请选择预约时间</span>
                    <span v-else>{{ currentDayContent }}</span>
                  </p>
                </div>
                <el-card v-if="popoverVisible" class="appointment-warp">
                  <h4>请选择预约时间</h4>
                  <div class="appointment-left">
                    <div class="head">
                      <i v-show="appointmentList&&appointmentList.length>1" class="el-icon-arrow-left" @click="forward" />
                      <div v-for="(item,index) in currentAppointment" :key="index" :class="currentDayInfo.day===item?'appointment-select':''" @click="selectAppointment(item, index)">
                        <span v-if="index===0">今天</span>
                        <span v-if="index===1">明天</span>
                        <span v-if="index===2">后天</span>
                        <span>{{ item }}</span>
                      </div>
                      <i v-show="appointmentList&&appointmentList.length>1" class="el-icon-arrow-right" @click="future" />
                    </div>
                    <div v-loading="$loadingPlugin.gettimeList" class="content">
                      <div v-for="(item, idx) in timePartList.appointmentTimeList" :key="idx" class="content-item" @click="selectTimePart(item,idx)">
                        <div class="time-item">
                          <p v-if="item.dateFlag&&item.dateFlag===1" class="time-count">
                            <span :class="item.select?'time-active':''">{{ item.endTime }} 前送达</span>
                          </p>
                          <p v-else class="time-count" :class="item.isFull?'p-disabel-gray':''">
                            <!-- <span :class="item.select?'time-active':''">{{ item.showIndex===0?currentAppointmentIndex===0?'今日送达':currentAppointmentIndex===1?'明日送达':currentAppointmentIndex===2?'后日送达':'':item.startTime+'~'+item.endTime }}</span><span v-if="item.isFull" class="dis">已约满</span><span v-if="!item.isFull && item.leftCount" class="count-left">{{ '(余' + item.leftCount + ')' }}</span> -->
                            <span :class="item.select?'time-active':''">{{ item.startTime+'~'+item.endTime }}</span><span v-if="item.isFull" class="dis">已约满</span><span v-if="(!item.isFull) && item.leftCount" class="count-left">{{ '(余' + item.leftCount + ')' }}</span>

                          </p>
                          <!-- <p>
                          <span>{{ item.startTime }}~{{ item.endTime }}</span><span v-if="false" class="dis">已约满</span>
                        </p> -->
                          <!-- <p class="p-disabel-gray">
                          <span>{{ item.startTime }}~{{ item.endTime }}</span><span v-if="item.isFull" class="dis">已约满</span>
                        </p> -->
                          <p v-if="item.select&&!item.isFull" :class="item.isFull?'p-disabel-gray':item.select?'time-active':''"> ✔ </p>
                        </div>
                      </div>
                      <p v-if="timePartList.appointmentTimeList.length===0" class="noAppointmentList">暂无可选时间段</p>
                    </div>
                  </div>
                  <div class="foot">
                    <el-button size="mini" @click="popoverVisible = false">取 消</el-button>
                    <el-button size="mini" type="primary" @click="confirmed">确 定</el-button>
                  </div>
                </el-card>
              </div>
            </el-form-item>
            <div v-if="TabsActiveName=='dingGou'">
              &nbsp;
              <el-checkbox v-if="PageOpitonsFn('加急')" v-model="submitForm.checkList.isUrgent" label="1">加急</el-checkbox>
              <el-checkbox v-if="PageOpitonsFn('需发票')" v-model="submitForm.checkList.isInvoice" label="1">需发票</el-checkbox>
              <el-checkbox v-if="PageOpitonsFn('自提')" v-model="submitForm.checkList.isPickUp" label="1" :disabled="ZiTiFlag" @change="changeIsPickUp">自提</el-checkbox>
              <el-checkbox v-if="PageOpitonsFn('补单')" v-model="submitForm.checkList.isRemedy" label="1">补单</el-checkbox>
              <!-- <el-checkbox v-if="PageOpitonsFn('月结')" v-model="submitForm.checkList.settlementType_monthly" label="1">月结</el-checkbox> -->
              <el-checkbox v-if="PageOpitonsFn('需回执')" v-model="submitForm.checkList.isRe" :disabled="HuiZhiFlag" label="1">需回执</el-checkbox>
              <el-checkbox v-if="PageOpitonsFn('托管')" v-model="submitForm.checkList.isZb" label="1">托管</el-checkbox>
              <!-- <el-checkbox v-if="anjianInfo!==1" v-model="submitForm.checkList.gasCheck" label="1">安检</el-checkbox> -->
              <!-- <span v-if="anjianInfo!==1" style="margin-left: 5px; font-size: 12px; color: #4b4cff;">勾选此项将向处理人下达一条定期安检任务单</span>
              <span v-else style="margin-left: 5px; font-size: 12px; color: #4b4cff;">已下达安检任务单</span> -->
              <el-form-item label="支付方式:" prop="paymentMethod" style=" display: inline-block; margin-bottom: 10px;">
                <el-radio-group v-model="submitForm.paymentMethod">
                  <!-- <el-radio v-if="prepaidCardInfo.settlementType===2" :disabled="canUseMonthly" :label="16">月结（{{ !canUseMonthly?((prepaidCardInfo.settlementUseMonery || 0 ).toFixed(2)+'/'+ (prepaidCardInfo.decimalSpare2 || 0 ).toFixed(2)):'用户余额不足，不可选择此支付方式' }}）</el-radio>
                  <el-radio v-if="(prepaidCardInfo.cardStatus===2 && prepaidCardInfo.settlementType===2) || (prepaidCardInfo.settlementType===1 && prepaidCardInfo.defaultPaymentMethod===256)" :label="256">预付卡（{{ ((prepaidCardInfo.cardSurplus || 0 )/100).toFixed(2) }}）</el-radio> -->
                  <!-- <el-radio v-if="cinfo.settlementType===2&&cinfo.monthlyUseOrgId === AddressData.orgId" :label="16">月结（{{ ((cinfo.settlementUseMonery || 0 ).toFixed(2)+'/'+ (cinfo.decimalSpare2 || 0 ).toFixed(2)) }}）</el-radio>
                  <el-radio v-else-if="cinfo.cardCode&&cinfo.cardUseOrgId === AddressData.orgId" :label="256">预付卡（{{ ((cinfo.cardSurplus || 0 )/100).toFixed(2) }}）</el-radio>
                  <template v-else>
                    <el-radio :label="1">现金</el-radio>
                    <el-radio :label="2">微信支付</el-radio>
                    <el-radio :label="128">支付宝</el-radio>
                    <el-radio :label="2024">门店扫码</el-radio>
                  </template> -->
                  <el-radio v-for="(item,i) in paymentMethodList" :key="i" :label="item.label">{{ item.name }}</el-radio>
                </el-radio-group>
              </el-form-item>
            </div>
          </el-form>
        </div>
        <div style="width: 10%;">
          <div v-if="TabsActiveName=='dingGou'" class="right_btns">
            <el-button type="primary" style="padding: 15px;" :loading="submitLoading" @click="submitOrder">提交订单（Shift+w）</el-button>
          </div>
          <div v-if="TabsActiveName=='baoXiu'" class="right_btns">
            <el-button type="primary" :loading="$loadingPlugin.submitOrderBaoXiu" @click="submitOrderBaoXiu">提交报修登记</el-button>
          </div>
          <div v-if="TabsActiveName=='touSu'" class="right_btns">
            <el-button type="primary" :loading="$loadingPlugin.submitOrderOthers" @click="submitOrderOthers('touSu','投诉')">提交投诉登记</el-button>
          </div>
          <div v-if="TabsActiveName=='tuiPing'" class="right_btns">
            <el-button type="primary" style="padding: 15px;" :loading="$loadingPlugin.submitOrderTuiPing2" @click="submitOrderTuiPing2">提交退瓶登记</el-button>
          </div>
          <div v-if="TabsActiveName=='qiTa'" class="right_btns">
            <el-button type="primary" :loading="$loadingPlugin.submitOrderOthers" @click="submitOrderOthers('qiTa','业务描述')">提交</el-button>
          </div>
        </div>
      </div>
    </div>
    <Urge ref="urge" />
    <BackOrder ref="backOrder" :get3order-history="get3orderHistory" @refresh3oroder="refresh3oroder" />
    <backOrderApply ref="backOrderApply" :get3order-history="get3orderHistory" />
    <Flow ref="flow" />
    <setting ref="setting" />
    <insure ref="insure" :org-tree-data="orgTreeData" :user-type="userType" @changeSaleMan="changeSaleMan" />
    <OhtersFlow ref="OhtersFlow" />
    <userDetail ref="userDetail" :tree-data="orgTreeData" :calc-type-list="calcTypeList" :paymen-fil-list="paymentMethodMap" />
    <location ref="location" />
    <order-detail
      ref="orderDetail"
      :payment-method-map="paymentMethodMap"
      :pay-status-map="payStatusMap"
      :transactor-list="transactorList"
      :order-flag-map="orderFlagMap"
      :order-source-map="orderSourceMap"
      :order-status-map="orderStatusMap"
    />
    <change-appointmentDt ref="changeAppointmentDt" :parent-fetch-data="refresh" />
    <showPreferential ref="showPreferential" />
  </div>
</template>

<script>

  // import phoneData from './phone'
  // import cmsCodeData from './cmsCard'
  // import cmstop3 from './cmstop3'
  // import qkparams from './qkparams'
  import dayjs from 'dayjs'
  import { parseTime } from '@/utils'
  import moment from 'dayjs'
  import getTreeData from '@/utils/jsonTree'
  import { treeToArray } from '@/utils/jsonTree'
  import { mapGetters } from 'vuex'
  import { getLocalSearch } from '@/utils/BMap'
  import { recheckbillCheck, depositinfoCheck, feeQueryByGood, confirmLonLat, accountopeningQuery, orderAppointment, queryInfoPhone, queryTransactorList, phoneOrderCallorderSetting, selectAreaCode, queryCsmTypeMap, phoneOrderSearchCms, phoneOrderServePrice, phoneOrdersumitRepair, phoneOrderDefineprice, getCodeNum, phoneOrderSubmit, searchOrgidList, phoneOrderFastSearch, phoneOrderFloorfee, phoneOrderGoodsPrices, goodsTypeQueryList, phoneOrderAreaprice, phoneOrderSearchspecialPrice, phoneOrderby3order, phoneOrderSearchLastOrder, phoneOrderDepositOrder, phoneOrderSaveUser, phoneOrderDelPhone, phoneOrderDelAddress, phoneOrderCsmGasCheck, phoneOrdersearchScore, phoneOrdersumitGiveback, phoneOrdersumitComplain, phoneOrdersumitOrderOther, queryOrderbillReturnParam, phoneOrderSearchCardList, phoneOrderSearchCardrules, searchCustomerdeposit, phoneOrderOtherPrice, queryMap, companySetting, givebackRgSave, orderbillCanUrge,
           getNearestStationInfoApi, getDepositOrderInfoApi
  } from '@/api'
  import { mergeAsyncFunc } from '@/utils/mergeAsyncFunc'
  import { accAdd } from '@/utils/math'
  import draggable from 'vuedraggable'
  import userDetail from '@/views/components/CsmDetailModal/index.vue'
  import OrderDetail from '../../orderCenter/orderManage/components/OrderDetails.vue'
  import Location from '../customerManage/components/Location.vue'
  import ChangeAppointmentDt from '../../components/ChangeAppointmentDt'
  import showPreferential from '../phoneOrder/components/showPreferential'
  export default {
    name: 'storeOrder',
    components: {
      // Repairs: require('./components/repairs.vue').default,
      BottleReturn: require('./components/bottleReturn.vue').default,
      Message: require('./components/message.vue').default,
      // Complaint: require('./components/complaint.vue').default,
      // Other: require('./components/other.vue').default,
      Urge: require('../../components/PressOrderModal').default,
      BackOrderApply: require('../../orderCenter/orderManage/components/BackOrderApply.vue').default,
      BackOrder: require('../../orderCenter/orderManage/components/BackOrder.vue').default,
      Flow: require('../../components/OrderFlowInfoModal').default,
      OhtersFlow: require('./Dialog/flow.vue').default,
      setting: require('./components/setting.vue').default,
      insure: require('./components/insure.vue').default,
      draggable,
      userDetail,
      OrderDetail,
      Location,
      ChangeAppointmentDt,
      showPreferential
    },
    directives: {
      scrollLoad: {
        bind(el, binding, vnode) {
          const wrapDom = el.querySelector('.el-autocomplete-suggestion__wrap')
          const listDom = el.querySelector('.el-autocomplete-suggestion__list')
          wrapDom.addEventListener(
            'scroll',
            e => {
              const condition =
                listDom.offsetHeight -
                wrapDom.offsetHeight +
                37 -
                0.3 -
                wrapDom.scrollTop
              if (condition < 0 && !vnode.context.loading) {
                // 滚动到底部则执行滚动方法load，binding.value就是v-scrollLoad绑定的值，加()表示执行绑定的方法
                binding.value()
              }
            },
            false
          )
        }
      }
    },
    data() {
      return {
        isFirst: false,
        paymentMethodList: [],
        paymentMethodMap: [],
        payStatusMap: [],
        transactorList: [],
        orderFlagMap: [],
        orderSourceMap: [],
        orderStatusMap: [],
        calcTypeList: [],
        submitLoading: false,
        isTrue: false,
        isLog: false,
        optionsArr: [
          { label: '客户电话', value: 1 },
          { label: '客户名称', value: 2 },
          { label: '客户编号', value: 3 },
          { label: '身份证', value: 4 },
          { label: '使用证', value: 5 },
          { label: '充值卡', value: 6 },
          { label: '开户电话', value: 7 }
        ],
        radioChoose: 1,
        height: 'auto',
        gdn: '',
        isShow: false,
        readOnly: false,
        depositOrderData: [],
        time0: undefined,
        time1: undefined,
        name: 'phoneOrder',
        btnStatus: false,
        radio1: null,
        TabsActiveName: 'dingGou',
        callObj: {}, // 来电数之类的数据
        isDefaultSky: true, // 是否显示默认盒子
        PageOpitons: [], // 下方的加急，回执等 选项配置
        businessLicense: false, // 系统配置  zzbh开启
        userType: [],
        cascaderSwitch: true, // 省市区级联选择的开关  为true时显示
        insureSeting: true, // 保险界面的开关  为true时显示
        menShiSwitch: false, // 呼叫下单时处理机构，仅显示门市级别
        levelSwitch: 0, // 呼叫下单所属机构默认展开层级
        expandedList: [], // 机构默认展开的节点
        expandAll: true, // 机构默认展开所有开关
        insureCodeFlag: true, // 保险编号的获取和输入开关
        treeKey: 0, // 机构key 刷新用
        cardList: [], // 证件列表zzbh
        csmInfo: null, // 保存提交的用户信息
        selectKey: 0,
        cacheSPrice: '', // 优惠价格
        lastOrderDetail: null, // 上次订单信息
        serach_phone: null,
        maxFloor: 99,
        selectPhoneIndex: null, // 用于是否删除关联电话
        goodsTreeData: [],
        goodsTreeDataDeatil: [],
        csmcodeFlag: false,
        orgTreeData: [],
        orgTreeDataReal: [], // 根据配置筛选过后使用的org数据
        goodsTypesDetailList: [],
        cascaderKey: 1,
        selectAddressFlag: false, // 地址选中状态
        addressRadio: null, // 地址的单选效果
        num: 0, // 首次搜索不抛出提示信息
        mainGoodsPrices: [], // 主营商品价格
        AreapriceList: [], // 区域价格
        ServePriceList: [], // 服务费
        FloorfeeList: [], // 上楼费
        orgId: null, // 组织id
        userData: [], // 处理人列表
        orgData: null, // 当前机构对象数据
        AddressData: {
          csmFloor: 1,
          orgId: null
        }, // 联系人地址信息
        contactInfo: {}, // 联系人详细信息
        contactData: {}, // 联系人电话和地址信息 存本地
        addressCascader: {}, // 级联选择对象
        checkDtStr: '', // 安检提示信息
        anjianInfo: null, // 安检勾选判断   来自后端
        HuiZhiFlag: false, // 回执勾选判断   来自sp2
        ZiTiFlag: false, // 自提disalble
        isPickUp: false,
        pickerOptions0: {
          disabledDate: (time) => {
            this.choiceDate = new Date() * 1
            const one = 24 * 3600 * 1000
            const minTime = this.choiceDate - one
            const maxTime = this.choiceDate + one * 4
            return time.getTime() < minTime || time.getTime() > maxTime
          }
        },
        rules: {
          sfzh: [{ required: true, message: '请输入正确的身份证号', trigger: 'change', pattern: /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/ }],
          zzbh: [{ required: true, message: '请输入资质编号', trigger: 'change' }],
          saleMan: [{ required: true, message: '请选择销售员', trigger: 'change' }],
          insurance: [{ required: true, message: '请选择保险时间', trigger: 'blur' }],
          insuranceMan: [{ required: true, message: '请输入售保人', trigger: 'change' }]
        },
        settingList: {
          // 身份证 sfzh 营业执照 zzbh 销售员 saleMan 保险 insurance  售保人 insuranceMan
          sfzh: true,
          zzbh: true,
          saleMan: true,
          insurance: true,
          insuranceMan: true
        },
        addressProps: {
          lazy: true,
          checkStrictly: true,
          lazyLoad(node, resolve) {
            const { level, value } = node
            mergeAsyncFunc(selectAreaCode, { areaCode: value || 0 })
              .then((res) => {
                const nodes = res.data.map(item => ({
                  value: item.areaCode,
                  label: item.areaName,
                  leaf: level >= 3
                }))
                resolve(nodes)
              })
              .catch(() => {
                node.loading = false
                node.loaded = false
              })
          }
        },
        temp: {
          insurance: [],
          'fromPlat': 1,
          'csmId': null,
          'csmCode': null,
          'csmName': null,
          'qrCode': null,
          'csmPhone': null,
          'contactPhone': null,
          'isPickUp': null,
          'contact': null,
          'csmAddressId': null,
          'csmAddress': null,
          'intSpare5': null,
          'csmType': null,
          'strSpare2': null,
          'saleMan': null,
          'lon': null,
          'lat': null,
          'orgId': null,
          'orgSNNo': null,
          'orgName': null,
          'ownerId': null,
          'ownerCode': null,
          'ownerName': null,
          'isUrgent': null,
          'isInvoice': null,
          'paymentMethod': null,
          'reStatus': null,
          'intSpare1': null,
          'remark': null,
          'orderFlag': null,
          zzbh: null
        },
        shortcutParams: {
          select: 1,
          csmPhone: null
        },
        orderForm: {
          orderFlag: null,
          goodsId: null
        },
        submitForm: {
          checkList: {},
          time: [],
          ownerId: null,
          paymentMethod: null
        },
        tableData: {
          column: [
            {
              prop: 'goodsName', label: '商品', align: 'center', width: 180
            },
            {
              prop: 'gprinceNum', label: '市价', align: 'center', width: '80',
              render: (h, { row, $index, column }) => {
                return (
                <div>
                  { (this.corpSettingData.sp5 >> 17 & 0x01) && row._edit && !row.definePrice ? (
                    <el-input class='EditInp' size='mini' value={row[column.property] } style='width: 80px' onBlur={(val) => { this.blurInput(row, column, val) }} onInput={(val) => { this.changeInput(row, column, val) }}> </el-input>
                  ) : (<span style={`textDecoration:${row.definePrice ? 'line-through;color:red' : ''}`}>{row[column.property] ? (row[column.property] * 1).toFixed(2) : 0}</span>)}
                </div>
              )
              }
            },
            {
              prop: 'definePrice', label: '特价', align: 'center', width: 80,
              // render: (h, { row, $index }) => <span>{row.definePrice ? row.definePrice : 0}</span>
              render: (h, { row, $index, column }) => {
                return (
                <div>
                  { row._edit && row.definePrice ? (
                    <el-input class='EditInp' size='mini' value={row[column.property] } style='width: 80px' onBlur={(val) => { this.blurInput(row, column, val) }} onInput={(val) => { this.changeInput(row, column, val) }}> </el-input>
                  ) : (<span >{row[column.property] ? (row[column.property] * 1).toFixed(2) : 0}</span>)}
                </div>
              )
              }
            },
            {
              prop: 'gprefPrice', label: '优惠', align: 'center', width: '80',
              render: (h, { row, $index, column }) => {
                return (
                <div>
                  { (this.corpSettingData.sp5 >> 25 & 0x01) && row._edit ? (
                    <el-input class='EditInp' size='mini' value={row[column.property] } style='width: 80px' onBlur={(val) => { this.blurInput(row, column, val) }} onInput={(val) => { this.changeInput(row, column, val) }}> </el-input>
                  ) : (<span >{row[column.property] ? (row[column.property] * 1).toFixed(2) : 0}</span>)}
                </div>
              )
              }
            },
            {
              prop: 'gcount', label: '数量', width: 80,
              render: (h, { row, $index, column }) => {
                return (
                <div>
                  {row._edit ? (
                    <el-input class='EditInp' maxlength='5' size='mini' value={row[column.property] } style='width: 80px' onBlur={(val) => { this.gcountblurInput(row, column, val) }} onInput={(val) => { this.changeInput(row, column, val) }}> </el-input>
                  ) : (<span >{row[column.property] ? (row[column.property] * 1) : ''}</span>)}
                </div>
              )
              }
              // render: (h, { row, $index }) => <el-input onBlur={(val)=>{this.blurInput(row,column,val)}} oninput={(e) => this.changeNum(row, $index, e)} v-model={row.gcount}></el-input>
            },
            {
              prop: 'fee1', label: '远距配送费', align: 'center', width: 80,
              render: (h, { row, $index, column }) => {
                return (
                <div>
                  { (this.corpSettingData.sp5 >> 19 & 0x01) && row._edit ? (
                    <el-input class='EditInp' maxlength='5' size='mini' value={row[column.property] } style='width: 80px' onBlur={(val) => { this.blurInput(row, column, val) }} onInput={(val) => { this.changeInput(row, column, val) }}> </el-input>
                  ) : (<span >{row[column.property] ? (row[column.property] * 1).toFixed(2) : 0.00}</span>)}
                </div>
              )
              }
            },
            {
              prop: 'fee2', label: '上楼费', align: 'center', width: 80,
              render: (h, { row, $index, column }) => {
                return (
                <div>
                  { (this.corpSettingData.sp5 >> 21 & 0x01) && row._edit ? (
                    <el-input class='EditInp' maxlength='5' size='mini' value={row[column.property] } style='width: 80px' onBlur={(val) => { this.blurInput(row, column, val) }} onInput={(val) => { this.changeInput(row, column, val) }}> </el-input>
                  ) : (<span >{row[column.property] ? (row[column.property] * 1).toFixed(2) : 0.00}</span>)}
                </div>
              )
              }
            },
            {
              prop: 'tip', label: '服务费', align: 'center', width: 80,
              render: (h, { row, $index, column }) => {
                return (
                <div>
                  { (this.corpSettingData.sp5 >> 23 & 0x01) && row._edit ? (
                    <el-input class='EditInp' maxlength='5' size='mini' value={row[column.property] } style='width: 80px' onBlur={(val) => { this.blurInput(row, column, val) }} onInput={(val) => { this.changeInput(row, column, val) }}> </el-input>
                  ) : (<span >{row[column.property] ? (row[column.property] * 1).toFixed(2) : 0.00}</span>)}
                </div>
              )
              }
              // render: (h, { row }) => <el-link onClick={() => this.openDetail(row)}>{row.orderCode}</el-link>
            },
            {
              prop: 'receivable', label: '总应收', align: 'center', width: '',
              render: (h, { row }) => <span >{this.goodsPrice(row)}</span>
            },
            {
              prop: '', label: '', align: 'center', width: '100',
              // render: (h, { row, $index }) => <span onClick={() => this.delGoods($index) }><i class='el-icon-close' style='color: red;' /></span>
              render: (h, { row, $index }) => {
                return (
                <div>
                    <el-link v-show={!this.isFirst } size='mini' underline={false} onClick={() => this.handleEdit(row)}>
                      {row._edit ? '' : '编辑'}
                    </el-link>
                    <el-link v-show={!this.isFirst } size='mini' underline={false} onClick={() => this.handleSave(row) } >
                      {row._edit ? '保存' : ''}
                    </el-link>
                    <el-link v-show={!this.isFirst } size='mini' underline={false} onClick={() => this.delGoods($index)}>
                      删除
                    </el-link>

                  </div>
                )
              }
            }

          ],
          data: []
        },
        tableDataScore: {
          column: [
            { label: '商品', prop: 'goodsName', width: 300 },
            { label: '单品积分', prop: 'priceScore', width: '', align: 'right' },
            { label: '数量', prop: 'gcount', width: '', align: 'right',
              render: (h, { row, $index, column }) => {
                return (
                <div>
                  {row._edit ? (
                    <el-input class='EditInp' size='mini' value={row[column.property] } style='width: 80px' onBlur={(val) => { this.orderNumBlurInput(row, column, val) }} onInput={(val) => { this.changeInput(row, column, val) }}> </el-input>
                  ) : (<span >{row[column.property] ? (row[column.property] * 1) : ''}</span>)}
                </div>
              )
              }
            },
            // { label: '现有库存', prop: 'storeCount', width: 80, align: 'right',, hidden: true },
            { label: '所需总积分', prop: 'requiredScore', width: '', align: 'right',
              render: (h, { row }) => <span >{this.goodsScores(row)}</span>
            },
            {
              prop: '', label: '', align: 'center', width: '200',
              // render: (h, { row, $index }) => <span onClick={() => this.delGoods($index) }><i class='el-icon-close' style='color: red;' /></span>
              render: (h, { row, $index }) => {
                return (
                <div>
                    <el-link size='mini' underline={false} onClick={() => this.handleEdit(row)}>
                      {row._edit ? '' : '编辑'}
                    </el-link>
                    <el-link size='mini' underline={false} onClick={() => this.handleSave(row) } >
                      {row._edit ? '保存' : ''}
                    </el-link>
                    <el-link size='mini' underline={false} onClick={() => this.delGoods($index)}>
                      删除
                    </el-link>

                  </div>
                )
              }
            }

          ],
          data: []
        },
        addressItems: [],
        addressRows: {}, // 当前选择的地址数据
        phoneItems: [],
        phoneData: {},
        cmsCodeData: {},
        cmstop3: [], // 最近三次订购数据
        qkparams: [], // 结果信息栏数据
        isBasePrice: '',
        plat: 4, // 话务下单   //4代表自提,
        EnumList2: [], // 订单来源枚举
        EnumList1: [], // 订单状态枚举
        prepaidCardInfo: {
          settlementUseMonery: '',
          decimalSpare2: '',
          settlementType: '',
          defaultPaymentMethod: '',
          cardSurplus: ''
        },
        canUseMonthly: true,
        list: [],
        cinfo: null,
        appointmentInfo: {},
        popoverVisible: false,
        showClear: false,
        currentDayContent: '',
        appointmentList: [],
        currentAppointment: [],
        currentAppointmentIndex: 0,
        currentDayInfo: {},
        timePartList: [],
        confirmedDayInfo: {},
        slectAddress: {},
        addressInfo: {
          page_num: 0,
          page_size: 10
        },
        suggestionCb: undefined,
        suggestionList: [],
        monthlyBillEndDt: '',
        monthlyBillTips1: '',
        monthlyBillTips2: '',
        recheckbill: false,
        isDeliver: null,
        firstDetails: []
      }
    },
    computed: {
      ...mapGetters([
        'orgList',
        'corpSettingData'
      ])

    },
    watch: {
      'submitForm.appointment': {
        handler(val) {
          if (val) {
            this.isTrue = true
          } else {
            this.isTrue = false
          }
        }
      },
      time0: {
        handler(val) {
          this.submitForm.time[0] = val
        }
      },
      time1: {
        handler(val) {
          this.submitForm.time[1] = val
        }
      },
      '$route': {
        handler(val) {
          if (val.path === '/customerCenter/storeOrder') {
            // 调整app-app-main-wrapper最小宽度
            setTimeout(() => {
              const dom = document.querySelector('.app-main-wrapper')
              // dom.style.minWidth = '1366px'
              dom.style.minWidth = ''
              dom.style.height = 'auto'
            })
          } else {
            setTimeout(() => {
              const dom = document.querySelector('.app-main-wrapper')
              dom.style.minWidth = ''
            })
          }
        },
        immediate: true
      },
      // submitForm.orgSNNo
      'submitForm.orgSNNo': {// 深度监听，可监听到对象、数组的变化
        handler(val, oldVal) {
          // console.log(val, oldVal)
          // console.log('orgTreeData', this.orgTreeData)
          var arr = treeToArray(this.orgTreeData).find(l => val === l.orgSNNo)
          this.orgData = arr
          this.search_OrgidList()
          this.getCardInfo()
        },
        deep: true // true 深度监听
      },
      'temp.csmType': {// 深度监听，可监听到对象、数组的变化
        handler(val, oldVal) {
          if (!this.num) {
            // 首次搜索不抛出类型变化提示信息
            this.num = 1
            return
          }
          // orderForm.orderFlag
          if (val === oldVal) return
          if (this.orderForm.orderFlag === 1 && this.tableData.data.length) {
            this.$message.warning('客户类型发生变化对应的区域价格可能发生变化,商品需重新选择')
            this.tableData.data = []
            this.tableDataScore.data = []
          } else if (this.orderForm.orderFlag === 2 && this.tableDataScore.data.length) {
            this.$message.warning('客户类型发生变化对应的兑换所需积分可能发生变化,商品需重新选择')
            this.tableData.data = []
            this.tableDataScore.data = []
            this.getGoodsTypeDetails(this.orderForm.gtId)
          }
        },
        deep: true, // true 深度监听
        immediate: false
      },
      'cinfo': {
        handler(newVal, oldVal) {
          // console.log('orgData', this.orgData)
          console.log('cinfo', this.cinfo)
          this.paymentMethodList = [{ label: 1, name: '现金' }]
          if (!this.orgData || !this.cinfo) {
            this.setPaymentMethod()
            return
          }
          // 默认支付方式
          // if (this.cinfo.monthlyUseOrgId === this.orgData.orgId && this.cinfo.defaultPaymentMethod === 16 && this.cinfo.settlementType === 2) {
          //  this.submitForm.paymentMethod = 16
          // } else if (this.cinfo.cardUseOrgId === this.orgData.orgId && this.cinfo.defaultPaymentMethod === 256 && this.cinfo.cardCode) {
          //  this.submitForm.paymentMethod = 256
          // } else if (this.cinfo.settlementType === 2 && this.cinfo.cardCode && this.cinfo.cardUseOrgId === this.orgData.orgId && this.cinfo.monthlyUseOrgId === this.orgData.orgId) {
          //  this.submitForm.paymentMethod = this.cinfo.defaultPaymentMethod
          // } else {
          //  this.submitForm.paymentMethod = null
          // }

          // 展示支付方式
          if (this.cinfo.settlementType === 2 && this.cinfo.monthlyUseOrgId === this.orgData.orgId && this.cinfo.cardCode && this.cinfo.cardUseOrgId === this.orgData.orgId) {
            this.paymentMethodList = [{ label: 16, name: `月结（${((this.cinfo.settlementUseMonery || 0).toFixed(2) + `/` + (this.cinfo.decimalSpare2 || 0).toFixed(2))}  ）` },
                                      { label: 256, name: `预付卡（${this.cinfo.isMainCard === 1 ? ((this.cinfo.cardSurplus || 0) / 100).toFixed(2) : `总可用金额:${((this.cinfo.mainCardSurplus + this.cinfo.deputyCardSurplus) / 100).toFixed(2)}  主卡:${(this.cinfo.mainCardSurplus / 100).toFixed(2)} 副卡:${(this.cinfo.deputyCardSurplus / 100).toFixed(2)}`}）` }]
            this.setPaymentMethod()
            return
          }

          if (this.cinfo.settlementType === 2 && this.cinfo.monthlyUseOrgId === this.orgData.orgId) {
            this.paymentMethodList = [{ label: 16, name: `月结（${((this.cinfo.settlementUseMonery || 0).toFixed(2) + `/` + (this.cinfo.decimalSpare2 || 0).toFixed(2))}  ）` }]
            this.setPaymentMethod()
            return
          }
          if (this.cinfo.cardCode && this.cinfo.cardUseOrgId === this.orgData.orgId) {
            this.paymentMethodList = [{ label: 256, name: `预付卡（${this.cinfo.isMainCard === 1 ? ((this.cinfo.cardSurplus || 0) / 100).toFixed(2) : `总可用金额:${((this.cinfo.mainCardSurplus + this.cinfo.deputyCardSurplus) / 100).toFixed(2)}  主卡:${(this.cinfo.mainCardSurplus / 100).toFixed(2)} 副卡:${(this.cinfo.deputyCardSurplus / 100).toFixed(2)}`}）` },
                                      { label: 1, name: '现金' }]
            this.setPaymentMethod()
            return
          }
          if (!this.cinfo.cardCode && this.cinfo.settlementType !== 2) {
            this.paymentMethodList = [{ label: 1, name: '现金' }]
          }
          if ((this.cinfo.settlementType === 2 && this.cinfo.monthlyUseOrgId !== this.orgData.orgId) || (this.cinfo.cardCode && this.cinfo.cardUseOrgId !== this.orgData.orgId)) {
            this.paymentMethodList = [{ label: 1, name: '现金' }]
          }
          this.setPaymentMethod()
        },
        deep: true,
        immediate: true
      },
      'monthlyBillEndDt': {
        handler(newVal, oldVal) {
          if (newVal) {
            const diff = dayjs(new Date()).diff(dayjs(newVal), 'days')
            this.monthlyBillTips1 = `月结客户(超过${diff}天未结清)`
            this.monthlyBillTips2 = `提示：该客户有月结单超过${diff}天未结清`
            this.$set(this.submitForm, 'remark', this.monthlyBillTips2)
          }
        },
        deep: true,
        immediate: true
      }
      // list(newVal, oldVal) {
      //   console.log('snewVal', newVal)
      //   console.log('soldVal', oldVal)
      // }
      // 'AddressData': {
      //   handler(newVal, oldVal) {
      //     console.log('newVal', newVal)
      //     console.log('oldVal', oldVal)
      //   },
      //   deep: true,
      //   immediate: true
      // }
      // 'cascaderKey': {// 深度监听，可监听到对象、数组的变化
      //   handler(val, oldVal) {
      //     // 地址信息

      //   },
      //   deep: true // true 深度监听
      // }
    },
    activated() {
      this.TabsActiveName = 'dingGou'
    },
    async  created() {
      if (this.corpSettingData.sp1 >> 29 & 0x01) {
        this.submitForm.checkList.isPickUp = true
      }
      // 回执
      if (this.corpSettingData.sp2 >> 27 & 0x01) {
        this.HuiZhiFlag = true
        this.$set(this.submitForm.checkList, 'isRe', true)
      }

      // 下单隐藏省市区
      if ((this.corpSettingData.sp3 >> 15 & 0x01)) {
        this.cascaderSwitch = false
      }
      // 隐藏保险相关信息$dlh.context.corpsetting.sp1>>11 & 0x01
      if ((this.corpSettingData.sp1 >> 11 & 0x01)) {
        this.insureSeting = false
        // 修改快捷查询样式
        setTimeout(() => {
          this.$refs.cardIsH560.$el.style.height = '560px'
        })
      }
      this.menShiSwitch = ((this.corpSettingData.sp1 >> 1 & 0x01)) // 呼叫下单时处理机构，仅显示门市级别
      this.levelSwitch = this.corpSettingData.sp1 >> 12 & 0x07 // 呼叫下单所属机构默认展开层级

      await this.getUserType()
      await this.getCallorderSetting()
      await this.getOrgTreeData()
      await this.getGoodsTreeData()
      await this.getGoodsPrices()
      await this.GetAreaprice()
      await this.GetServePrice()
      await this.GetFloorfee({})
      await this.getcompanySetting()
      await this.getEnum1()
      await this.getEnum2()
      await this.getEnum3()
      await this.getEnum4()
    },
    mounted() {
      this.setHight()
      // const vm = this
      // this.tags = [
      //   { id: 0, ele: document.getElementsByClassName('cardone')[0] },
      //   { id: 1, ele: document.getElementsByClassName('cardtwo')[0] },
      //   { id: 2, ele: document.getElementsByClassName('cardthree')[0] }
      // ]
      this.keyCodeForEvent()
      /* this.isBasePrice = this.plat === 4 && (this.corpSettingData.sp1 >> 23 & 0x01) > 0 */
      this.$watch('orderForm.orderFlag', (val) => {
        this.tableData.data = []
        this.tableDataScore.data = []
        if (val === 1) {
          this.goodsTreeDataDeatil = this.goodsTreeData.filter(l => l.gtCategory === 1)
          setTimeout(() => {
            // this.$set(this.orderForm, 'gtId', this.goodsTreeDataDeatil[0].gtId)
            // this.orderForm.gtId = this.goodsTreeDataDeatil[0].gtId
            this.goodsTypesDetailList = []
            if (this.isLog) this.selectTreeChange(this.goodsTreeDataDeatil[0])
          }, 0)
        } else if (val === 2) {
          this.goodsTreeDataDeatil = this.goodsTreeData.filter(l => l.gtCategory === 4)
          this.orderForm.gtId = null
          this.orderForm.goodsId = null
          setTimeout(() => {
            // this.$set(this.orderForm, 'gtId', this.goodsTreeDataDeatil[0].gtId)
            // this.orderForm.gtId = this.goodsTreeDataDeatil[0].gtId
            this.goodsTypesDetailList = []
            if (this.isLog) this.selectTreeChange(this.goodsTreeDataDeatil[0])
          }, 0)
        }
      }, { deep: true })
      this.radioChoose = localStorage.getItem('refershQkparam') || 1
      this.radioChoose = Number(this.radioChoose)
      this.shortcutParams.select = this.radioChoose
    },
    methods: {
      parseTime,
      dayjs,
      moment,
      // 支付方式 （1）如果支付方式只有一种，默认勾选；（2）有多种支付方式的话，默认不勾选
      setPaymentMethod() {
        if (this.paymentMethodList.length > 1) {
          this.submitForm.paymentMethod = null
        }
        if (this.paymentMethodList.length === 1) {
          this.submitForm.paymentMethod = this.paymentMethodList[0].label
        }
      },
      // 优惠剩余瓶数详情
      showPreferentialDialog() {
        if (this.addressRows.preferentialCount) {
          this.$refs.showPreferential.open(this.addressRows, 4)
        }
      },
      // 点击订单号
      async openOrderDetail(row) {
        await this.$refs.orderDetail.open(row)
      },
      // 获取下单人列表
      async getTransactorList() {
        const res = await queryTransactorList({})
        this.transactorList = res.data
      },
      isDaoqi() {
        if (!this.temp.insurance) return false
        if (!this.temp.insurance.length) return false
        const today = dayjs(new Date()).valueOf()
        const lastday = dayjs(this.temp.insurance[1]).subtract(3, 'day').valueOf()
        if (today > lastday) {
          return true
        }
        return false
      },
      haveTime(val) {
        if (val) {
          this.$set(this.submitForm, 'appointment', dayjs(new Date()).format('YYYY-MM-DD'))
        } else {
          this.$set(this.submitForm, 'appointment', '')
        }
      },
      typeChange(val) {
        this.$forceUpdate()
      },
      changRadio() {
        // 保存默认
        localStorage.setItem('refershQkparam', this.radioChoose)
        this.$message.success('保存默认成功')
      },
      changeGoods(value) {
        this.readOnly = false
        if (this.orderForm.goodsCount) {
          this.tableData.data = []
          this.tableDataScore.data = []
          for (let i = 0; i < this.orderForm.goodsCount; i++) {
            this.addGoods({})
          }
        }
      },
      setHight() {
        setTimeout(() => {
          const ch = this.$refs.cardRef.clientHeight
          const fh = this.$refs.dataForm.$el.clientHeight
          const oh = this.$refs.orderRef.clientHeight
          this.height = ch + fh + oh + 20 + 'px'
        }, 500)
      },
      openUserDetail() {
        this.$refs.userDetail.open(this.temp)
        // console.log('客户详情')
      },
      // 订单状态枚举
      async getEnum1() {
        const res = await queryMap({ enumName: 'OrderStatus' })
        this.EnumList1 = res.data
        this.orderStatusMap = res.data.filter((item) => item.value !== 6) // 订单类型(去掉‘已转派’)
        return 1
      },
      // 订单来源枚举
      async getEnum2() {
        const res = await queryMap({ enumName: 'OrderSource' })
        this.EnumList2 = res.data
        this.orderSourceMap = res.data // 订单来源
        return 2
      },
      // 订单类型枚举
      async getEnum3() {
        const res = await queryMap({ enumName: 'OrderFlag' })
        this.orderFlagMap = res.data // 订单类型
        return 3
      },
      // 收款方式枚举
      async getEnum4() {
        const res = await queryMap({ enumName: 'CalcType' })
        this.calcTypeList = res.data // 收款方式
        return 4
      },
      // 企业配置查询
      async getcompanySetting() {
        const res = await companySetting()
        if (res.data && res.data.rows && res.data.rows.length) {
          const data = res.data.rows[0]
          this.companySetting = data
          if (this.cascaderSwitch) { // 流程配置省市区不隐藏时
            var list = [data.provinceCode, data.cityCode, data.countyCode]
            list = list.filter(l => l * 1 !== 0)
            this.AddressData.address = [...list]
            this.cascaderKey++
          } else {
            this.AddressData.address = []
          }
        }
        //  通知级联地址选择框回显
        // console.log(res)
      },
      getdata(evt) {
        // console.log(evt.draggedContext.element, 'evt.draggedContext.element')
        // console.log(evt.draggedContext.element.id)
      },
      datadragEnd(evt) {
        // console.log(evt, 'evt')
        // console.log('拖动前的索引 :' + evt.oldIndex)
        // console.log('拖动后的索引 :' + evt.newIndex)
        // console.log(this.tags)
      },
      // addCsmChange(e) {
      //   if (!this.temp.csmId) {
      //     this.$set(this.contactInfo, 'csmPhone', e.target.value)
      //   }
      // },
      paymentMethodChange() {
        /* this.checkMonthly() */
      },
      /* checkMonthly() {
        if (this.form.paymentMethod === 16) {
          if (this.form.description.indexOf(5) === -1) {
            this.form.description.push(5)
          }
        } else {
          if (this.form.description.length > 0) {
            this.form.description = this.form.description.filter(item => item !== 5)
          }
        }
      }, */
      contactBlur(e) {
        if (!this.temp.csmId) {
          this.$set(this.contactInfo, 'contact', e.target.value)
        }
      },
      async getUserType() {
        try {
          const res = await queryCsmTypeMap()
          this.userType = res.data
        } catch (error) {
          console.log(error)
        }
      },
      // 查询窗体配置
      // phoneOrderCallorderSetting
      async getCallorderSetting() {
        try {
          const res = await phoneOrderCallorderSetting()
          this.businessLicense = res.data.businessLicense * 1
          this.PageOpitons = JSON.parse(res.data.orderOptions)
          this.callObj = { ...res.data }
        } catch (e) {
          console.log(e)
        }
      },
      // 下方加急，回执等选项配置
      PageOpitonsFn(val) {
        if (this.PageOpitons.length > 0) {
          var obj = this.PageOpitons.find(l => l.keyName === val)
          var flag = false
          if (obj && obj.keyStatus) {
            obj.keyStatus === 1 ? flag = false : flag = true
          }
          return flag
        } else {
          return true
        }
      },
      // 获取用户编号
      async getCmsCode(type) {
        const res = await getCodeNum({ type })
        if (type === 2) {
          this.$set(this.temp, 'csmCode', res.data)
          // this.temp.csmCode = res.data
        } else if (type === 10) {
          this.$set(this.temp, 'insureCode', res.data)
          // this.temp.insureCode = res.data
        }
        // this.param
      },
      // 模拟组合键触发函数
      keyCodeForEvent() {
        const vm = this

        let code = 0
        let code2 = 0
        document.onkeydown = function(e) {
          const evn = e || event
          const key = evn.keyCode || evn.which || evn.charCode
          if (key === 16) {
            code = 1
          }
          if (key === 83) {
            code2 = 1
          }
          if (key === 87) {
            code2 = 2
          }
          if (code === 1 && code2 === 1) {
            // alert('shift+S')
            vm.submitOrderKeep()
            // this obj to do something
            code = 0
            code2 = 0
          }
          if (code === 1 && code2 === 2) {
            // alert('shift+W')
            vm.submitOrder()
            // this obj to do something
            code = 0
            code2 = 0
          }
        }
        document.onkeyup = function(e) {
          if (e.keyCode === 16) {
            code = 0
          }
          if (e.keyCode === 83) {
            code2 = 0
          }
          if (e.keyCode === 87) {
            code2 = 0
          }
        }
      },
      changeInsureCode(e) {
        const value = e.target.value
        const reg = /^[A-Za-z0-9]+$/
        if (!reg.test(value) && e.target.value !== '') {
          this.$message.error('保单号只能输入字母和数字')
          this.temp.insureCode = ''
        }
      },
      async searchForPhone(flag = true, querycsmId) {
        if (flag && !this.serach_phone) {
          this.$message.warning('请输入电话号码')
          return
        }
        this.isLog = false
        this.addressRadio = null
        this.btnStatus = true
        setTimeout(() => {
          this.btnStatus = false
        }, 1000)
        this.isShow = false
        this.num = 0 // 首次搜索不抛出类型变化提示信息
        // flag 为真时  表示是快捷查询
        this.orderForm.orderFlag = 1 // 默认切换到购买
        this.tableData.data = [] // 初始化订单表格
        this.ZiTiFlag = false // 初始化自提勾选
        this.isPickUp = false // 初始化自提勾选
        // this.$set(this.submitForm.checkList, 'isPickUp', false)// 初始化自提勾选
        let params = {}
        if (querycsmId) {
          params = { csmId: querycsmId, phone: '', fromPlat: 4 }
        } else {
          params = { csmId: 0, phone: this.serach_phone, fromPlat: 4 }
        }
        const res = await phoneOrderSearchCms(params)
        this.phoneData = res.data
        if (!this.cinfo) {
          const res1 = await queryInfoPhone({ csmId: res.data.csmId, phone: this.serach_phone })
          this.temp.qrCode = res1.data.qrCode
          this.cinfo = res1.data
          this.monthlyBillEndDt = res1.data.monthlyBillEndDt
        }
        if (!res.data) {
          this.$message.warning('没有查询到对应客户信息')
          this.reset()
          this.$set(this.contactInfo, 'csmPhone', this.serach_phone)
          if (this.cascaderSwitch && this.companySetting) { // 流程配置省市区不隐藏时
            // 公司默认地址
            var list = [this.companySetting.provinceCode, this.companySetting.cityCode, this.companySetting.countyCode]
            list = list.filter(l => l * 1 !== 0)
            this.AddressData.address = [...list]
            this.cascaderKey++
          } else {
            this.AddressData.address = []
          }
          // if (!this.AddressData.csmFloor) this.AddressData.csmFloor = 1
          this.$set(this.AddressData, 'csmFloor', 1)
          return
        }

        this.phoneItems = this.phoneData.phoneItems.filter(l => l.cpStatus !== -1)
        this.addressItems = this.phoneData.addressItems
        this.$nextTick(async function() {
          // 初始化关联地址选择
          if (this.addressItems.length === 1) {
            await this.selectAddress(0, this.addressItems[0])
          } else {
            await this.selectAddress()
            if (this.cascaderSwitch && this.companySetting) { // 流程配置省市区不隐藏时
              // 公司默认地址
              var list = [this.companySetting.provinceCode, this.companySetting.cityCode, this.companySetting.countyCode]
              list = list.filter(l => l * 1 !== 0)
              this.AddressData.address = [...list]
              this.cascaderKey++
            } else {
              this.AddressData.address = []
            }
          }
          // 初始化关联电话选择
          var dataitem = this.phoneItems.find(l => l.csmPhone === this.phoneData.csmRgPhone)
          var index = this.phoneItems.findIndex(l => l.csmPhone === this.phoneData.csmRgPhone)
          this.selectPhoneIndex = index
          this.selectPhone(index, dataitem)
          if (this.TabsActiveName !== 'dingGou') { // 当前在的tabs调接口更新数据
            this.$refs[this.TabsActiveName].getData(this.temp.csmId)
          }
        })
        this.temp = { ...this.temp, ...JSON.parse(JSON.stringify(res.data)), zzbh: '' }
        this.get3orderHistory()

        // 通过电话获取到cmsCode
        var csmCode = this.phoneData.csmCode
        if (csmCode) {
          // 余额
          this.getDepositOrder()
        }
        // 证件(弃用)
        // if (this.businessLicense) {
        //  this.searchCards()
        // }
        // 销售人员
        this.$set(this.temp, 'saleMan', this.phoneData.salesmanName)
        this.$set(this.temp, 'saleManId', this.phoneData.salesman)
        this.csmcodeFlag = true
        this.insureCodeFlag = true
        this.$set(this.temp, 'insurance', [])
        // this.temp.insurance = []
        if (this.corpSettingData.sp1 >> 3 & 0x01) {
          this.$set(this.submitForm, 'remark', this.temp.remark)
          // this.submitForm.remark = this.temp.remark
        } else {
          // this.submitForm.remark = ''
          // this.$set(this.submitForm, 'remark', '')
        }
        // 判断是否为自提客户
        if (this.temp.isPickUp > 0) {
          if (this.plat === 4) {
            this.$message.warning('此客户是自提客户,本次订单自动默认为自提')
            this.isPickUp = true
            this.$set(this.submitForm.checkList, 'isPickUp', true)
            this.ZiTiFlag = true
            // this.getObj('ck_order_isPickUp').prop('checked', true)
          } else {
            this.$message.warning('此客户是自提客户,如若需自提请勾选订单自提')
          }
        }

        if (flag) {
          // await this.getFastSearchInfo()
          this.shortcutParams.select = 1
          this.shortcutParams.csmPhone = this.serach_phone
          await this.fastSearch(false)
        }
        this.selectKey++
        if (!this.AddressData.csmFloor || this.AddressData.csmFloor === '0') this.AddressData.csmFloor = 1
      },
      // 刷新最近三次订单
      refresh3oroder() {
        this.get3orderHistory()
        if (this.TabsActiveName === 'xinXi') {
          this.$refs.xinXi.getData(this.temp.csmId)
        }
      },
      // 查询上次订单
      async searchLastOrder(csmAddressId = '') {
        const params = {
          csmId: this.temp.csmId,
          csmAddressId
        }
        if (!params.csmId || !csmAddressId) {
          return
        }
        try {
          const res = await phoneOrderSearchLastOrder(params)
          if (res.data) {
            // await this.getGoodsTypeDetails(res.data.gtId, false)
            // await this.addGoods(res.data)
            // this.tableData.data = [res.data]
            this.lastOrderDetail = res.data
            this.gdn = res.data.goodsName
            // this.isShow = true
            // setTimeout(() => {
            //   this.isShow = false
            // }, 10000)
            if (this.lastOrderDetail) {
              // this.addGoods(res.data)
              // this.tableData.data.push(this.lastOrderDetail)
            }
          }
        } catch (e) {
          console.log(e)
        }
      },
      // 获取余额
      async getDepositOrder() {
        // console.log(this.temp)
        if (this.temp.cardCount <= 0) {
          return
        }
        try {
          const res = await phoneOrderDepositOrder({ csmCode: this.phoneData.csmCode })
          if (res.data) {
            this.cmsCodeData = res.data
          }
        } catch (e) {
          console.log(e)
        }
      },
      // 客户信息快速查询
      async getFastSearchInfo() {

      },
      // 订气记录
      async get3orderHistory(value = 3) {
        try {
          const params = {
            csmId: this.temp.csmId,
            topCount: value
          }
          const res = await phoneOrderby3order(params)
          this.cmstop3 = res.data
          if (this.cmstop3.length > 0) {
            this.orderForm.gtId = this.cmstop3[0].detailList[0].gtId
            await this.getGoodsTypeDetails(this.orderForm.gtId)
            const csmAddressId = this.cmstop3[0].csmAddressId
            this.addressItems.forEach(async(item, index) => {
              if (item.csmAddressId === csmAddressId) {
                await this.selectAddress(index, item)
              }
            })
          } else {
            this.orderForm.gtId = this.goodsTreeDataDeatil[0].gtId
            await this.getGoodsTypeDetails(this.orderForm.gtId)
          }
        } catch (e) {
          console.log(e)
        }
      },
      // 获取所属机构数据
      async getOrgTreeData() {
        // const res = await organizationQueryList({})
        const data = this.orgList.map(item => ({
          label: item.name,
          ...item
        }))
        this.orgTreeData = getTreeData(data)
        if (this.menShiSwitch && this.levelSwitch <= 1) {
          this.orgTreeDataReal = getTreeData(data.filter(l => l.orgType === 11))
        } else if (this.levelSwitch > 1) {
          this.expandAll = false
          this.orgTreeDataReal = this.orgTreeData
          this.expandedList = ['001139001000000000000'] // 未做完
          this.treeKey++
        } else {
          this.orgTreeDataReal = this.orgTreeData
        }
      },

      async selectOrgTreeChange(value) {
        if (this.tableData.data.length > 0 || this.tableDataScore.data.length > 0) {
          this.$message.warning('机构发生变化对应的区域价格可能发生变化,商品需重新选择')
        }
        this.tableData.data = []
        this.tableDataScore.data = []
        this.orgSNNo = value.orgSNNo
        // this.submitForm.orgSNNo = value.orgSNNo
        this.orgData = { ...value }
        this.orderForm.goodsId = null
        this.AddressData = { ...this.AddressData, ...value }
        // 大车司机不变更责任机构
        if (this.cinfo.driverOrgSNNo) {
          this.$set(this.submitForm, 'orgSNNo', this.cinfo.driverOrgSNNo)
          this.$set(this.submitForm, 'orgId', this.cinfo.driverOrgId)
        }
        // 处理人、预约时间取订单责任机构
        this.orgId = this.submitForm.orgId // 责任机构查询处理人需要的id
        const orgInfo = this.orgList.filter((item) => {
          return item.orgId === this.submitForm.orgId
        })
        this.appointmentInfo = orgInfo.length ? orgInfo[0] : {}
        this.$set(this.submitForm, 'ownerId', null)
        await this.search_OrgidList() // 责任机构处理人
        await this.queryGoods()
        if (this.temp.csmId) await this.firstOrder(this.temp.csmId)
        this.getTimeClear()
        this.gettimeList()
        this.popoverVisible = false
        // this.orderForm.gtId = null
      },
      // 储存当前机构对象
      saveOrgData() {
        this.orgData = this.orgList.find(l => l.orgSNNo === this.submitForm.orgSNNo) || null
      },
      // 级联选择
      async selectCascader(val) {
        // this.cascaderKey++

        // if (!val) return
        // var pathLabels = this.$refs.cascader.getCheckedNodes()[0].pathLabels
        // this.addressCascader = {
        //   provinceName: pathLabels[0],
        //   provinceCode: val[0],
        //   cityName: pathLabels[1],
        //   cityCode: val[1],
        //   countryName: pathLabels[2],
        //   countryCode: val[2],
        //   streetName: pathLabels[3],
        //   streetCode: val[3]
        // }
      },
      // 获取当前级联选择的地址信息 用于表单提交
      getAddressCascaderInfo() {
        if (this.cascaderSwitch && this.AddressData.address) { // 级联配置打开的情况
          var pathLabels = this.$refs.cascader.getCheckedNodes()[0] ? this.$refs.cascader.getCheckedNodes()[0].pathLabels : []
          this.addressCascader = {
            provinceName: pathLabels[0] || '',
            provinceCode: this.AddressData.address[0] || '000000',
            cityName: pathLabels[1] || '',
            cityCode: this.AddressData.address[1] || '000000',
            countryName: pathLabels[2] || '',
            countryCode: this.AddressData.address[2] || '000000',
            streetName: pathLabels[3] || '',
            streetCode: this.AddressData.address[3] || '000000'
          }
        } else {
          this.addressCascader = {
            provinceName: '',
            provinceCode: '000000',
            cityName: '',
            cityCode: '000000',
            countryName: '',
            countryCode: '000000',
            streetName: '',
            streetCode: '000000'
          }
        }

        return this.addressCascader
      },
      // 查询证件列表
      async searchCards() {
        const params = {
          currentPage: 1,
          pageSize: 999,
          csmId: this.temp.csmId,
          cardType: 4
        }
        if (!params.csmId) return
        const res = await phoneOrderSearchCardList(params)
        var list = res.data
        if (list && list.length) {
          // var arr = list.filter(l => l.cardType === 4)
          var arr = list.map(l => {
            return { value: l.cardNo, text: l.cardNo }
          })
          this.cardList = arr // 证件编号列表
          if (this.cardList.length) {
            this.$set(this.temp, 'zzbh', arr[0].value)
          }
        } else {
          // this.temp.zzbh = null
          this.cardList = []
        }
        // this.temp = { ...this.temp }
      },
      // 添加并校验证件列表
      async rulesCards(csmId, cardNo, cardType) {
        const params = {
          csmId, cardNo, cardType
        }
        return phoneOrderSearchCardrules(params).then(res => {
          if (res.data !== '0') {
            this.$message.error('营业执照编号重复，请重新输入')
            return false
          }
          return true
        })
      },
      // 资质编号变化
      WOStatusChange(value) {
        if (value) {
          this.temp.zzbh = value
        }
      },
      zzbhBlur(value) {
        if (value.target.value) {
          this.temp.zzbh = value.target.value
        }
      },
      getCsmInfo() {
        this.csmInfo = {}
        this.csmInfo.csmCode = this.temp.csmCode
        this.csmInfo.csmName = this.temp.csmName
        this.csmInfo.csmRgPhone = this.contactInfo.csmPhone

        // if (this.plat === 4) {
        //   if (this.getObj('ck_order_csm_isPickUp').prop('checked')) {
        //     this.csmInfo.isPickUp = 1
        //   } else {
        //     this.csmInfo.isPickUp = this.csmInfo.csmId ? -1 : 0
        //   }
        // }

        // var csmAddress=$.trim(this.getObj("txt_order_contactaddress").val()).replace(/[\r\n]/g,"");
        var csmAddress = this.AddressData.csmAddress.replace(/[\r\n]/g, '')
        this.csmInfo.csmRgAddress = csmAddress
        // 隐藏省市区客户地址不保存
        if (!(this.corpSettingData.sp3 >> 15 & 0x01)) {
          this.csmInfo = { ...this.csmInfo, ...this.addressCascader }
        } else {
          this.csmInfo.provinceCode = null
          this.csmInfo.provinceName = null
          this.csmInfo.cityCode = null
          this.csmInfo.cityName = null
          this.csmInfo.countryCode = null
          this.csmInfo.countryName = null
          this.csmInfo.streetCode = null
          this.csmInfo.streetName = null
        }

        this.csmInfo.sfzh = this.temp.sfzh
        // 地址里有换行符时，此处的比较会有问题，需要把换行符替换掉
        if (this.csmInfo.csmAddressId && (!this.csmInfo.csmRgAddress || csmAddress !== this.csmInfo.csmRgAddress)) {
          this.csmInfo.csmAddressId = 0
          delete this.csmInfo.insureEndDt
        }
        this.csmInfo.csmRgAddress = csmAddress
        this.csmInfo.contact = this.contactInfo.contact
        this.csmInfo.csmFloor = this.AddressData.csmFloor
        this.csmInfo.doorplate = this.AddressData.doorplate
        this.csmInfo.csmType = this.temp.csmType * 1
        if ((this.csmInfo.csmName || '') === '') {
          this.csmInfo.csmName = this.csmInfo.contact
        }

        var orgInfo = this.orgData
        if (orgInfo) {
          this.csmInfo.orgId = orgInfo.orgId
          this.csmInfo.orgName = orgInfo.orgName
          this.csmInfo.orgSNNo = orgInfo.orgSNNo
        }
        var salesmanname = this.temp.saleMan
        this.csmInfo.salesmanName = salesmanname
        if (salesmanname !== '') {
          this.csmInfo.salesmanName = salesmanname
          var salesman = this.temp.saleManId
          this.csmInfo.salesman = salesman
          if (!salesman) {
            this.csmInfo.salesman = 0
          }
        } else {
          this.csmInfo.salesman = 0
        }
        this.csmInfo.remark = this.temp.remark
        this.csmInfo.insureCode = this.temp.insureCode
        this.csmInfo.insureEndDt = this.temp.insurance ? this.temp.insurance[1] : ''
        this.csmInfo.insureStartDt = this.temp.insurance ? this.temp.insurance[0] : ''
        // 来源话务下单编辑客户
        this.csmInfo.comeFromEdit = 2
        // 配置相关
        if (!this.temp.csmId && (this.corpSettingData.sp1 >> 5 & 0x01) === 0x01) {
          this.csmInfo.csmStatus = 1
        }
        this.csmInfo.zzbh = this.temp.zzbh
        this.csmInfo.zzbhFlag = this.cardList.length ? 0 : 1
        this.csmInfo.isPickUp = this.isPickUp ? 1 : -1
        this.csmInfo = { ...this.phoneData, ...this.csmInfo }
        /*	this.csmInfo.orgId=$dlh.tools.convert.toInt(this.getObj("cbo_order_csmorg").combobox("getValue"));
	this.csmInfo.orgName=this.getObj("cbo_order_csmorg").combobox("getText");*/
        return this.csmInfo
      },
      // 保存客户
      async saveUser() {
        //  弃用查询客户证件信息
        // this.searchCards()
        const vm = this
        this.addressRadio = null
        if (this.temp.phoneItems && !this.temp.csmId) {
          // alret('111')
        }
        try {
          if (!vm.temp.csmCode) {
            vm.$message.warning('未获取到客户编号')
            return
          }
          if (!vm.contactInfo.contact) {
            vm.$message.warning('请填写联系人姓名')
            return
          }
          if (!this.orgData || !this.AddressData.orgSNNo) {
            vm.$message.warning('请选择组织机构')
            return
          }
          if (this.cascaderSwitch) {
            if ((!this.AddressData.address) || !this.AddressData.csmAddress) {
              vm.$message.warning('请填写省市区地址和详细地址')
              return
            }
          } else {
            if (!this.AddressData.csmAddress) {
              vm.$message.warning('请填写客户详细地址')
              return
            }
          }
          if (vm.temp.insurance && vm.temp.insurance.length) {
            const time0 = dayjs(vm.temp.insurance[0]).valueOf()
            const time1 = dayjs(vm.temp.insurance[1]).valueOf()
            if (time0 >= time1) return vm.$message.warning('保险结束日期不能小于开始日期')
          }
          this.submitForm.remark = this.temp.remark
          this.getAddressCascaderInfo()
          this.getCsmInfo()
          // var flag = await vm.$refs.dataForm.validate()
          // var flag2 = await vm.$refs.dataFormRight.validate()
          // if (!flag || !flag2) {
          //   vm.$message.warning('请完成表单必填项')
          // }

          // 启用实名制开户1346505588 this.corpSettingData.sp1
          if ((this.corpSettingData.sp1 >> 30 & 0x01) > 0) {
            var reg = /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/
            if (!this.temp.sfzh) {
              this.$message.error('请输入身份证号!')
              return
            }

            if (this.temp.sfzh && !reg.test(this.temp.sfzh)) {
              this.$message.error('身份证号格式不正确')
              return
            }
          }
          if (this.businessLicense) {
            if (this.temp.csmType === 4 || this.temp.csmType === 2) {
              if (this.cardList.length) {
                if (!this.temp.zzbh) {
                  this.$message.error('请选择营业执照编号')
                  return
                } else {
                  // context.csmInfo.zzbh = context.getObj('txt_order_csm_select_zzbh').combobox('getValue')
                }
              } else {
                if (!this.temp.zzbh) {
                  this.$message.error('请输入营业执照编号')
                  return
                } else {
                  var flag = await this.rulesCards(this.phoneData.csmId, this.temp.zzbh, 4)
                  if (!flag) {
                    return
                  }
                }
              }
            }
          }

          var addrRow = this.addressRows
          if (this.csmInfo.csmAddressId === 0 && addrRow) {
            var addrRows = this.phoneData.addressItems
            for (var i in addrRows) {
              var item = addrRows[i]
              if (item.csmAddress === this.csmInfo.csmRgAddress) {
                this.csmInfo.csmAddressId = item.csmAddressId
                break
              }
            }
            if (this.selectAddressFlag) { // 关联地址处于选中状态
              if (this.csmInfo.csmAddressId === 0) {
                this.$confirm('您是要修改选中的关联地址还是新增一个新地址?', '提示', {
                  confirmButtonText: '修改',
                  cancelButtonText: '新增',
                  distinguishCancelAndClose: true,
                  type: 'warning'
                })
                  .then(() => {
                    this.csmInfo.csmAddressId = this.addressRows.csmAddressId
                    vm.save()
                  })
                  .catch((action) => {
                    // this.$message.info('已取消删除操作')
                    if (action === 'cancel') {
                      this.csmInfo.csmAddressId = 0
                      vm.save()
                    } else {
                      1
                    }
                  })
                return
              }
            }
          }
          this.save()
        } catch (e) {
          console.log(e)
        }
      },
      async  save() {
        var params = { ...this.csmInfo }
        this.$confirm('您是要修改选中的关联地址还是新增一个新地址?', '提示', {
          confirmButtonText: '新增',
          cancelButtonText: '修改',
          type: 'warning'
        }).then(async() => {
          params.csmAddressId = 0
          params.lon = this.AddressData.longitude.toFixed(6)
          params.lat = this.AddressData.latitude.toFixed(6)
          const res = await phoneOrderSaveUser(params)
          if (res.data) {
            this.temp = { ...this.temp, ...res.data, csmAddressId: res.data.addressId }
            this.temp.csmId = res.data.csmId
            await this._setRelation(res.data.csmId)
            if (this.addressItems.length === 1) {
              this.selectAddress(0, this.addressItems[0])
            }
          }
          if (res.success) {
            // this.searchCards()
            this.$message.success('保存成功')
          }
          this.btnStatus = false
        }).catch(async() => {
          if (this.temp.qrCode) {
            this.$confirm('用户已绑定一户一码，确认变更地址吗?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(async() => {
              params.qrCode = this.temp.qrCode
              // console.log(params)
              params.lon = this.AddressData.longitude.toFixed(6)
              params.lat = this.AddressData.latitude.toFixed(6)
              const res = await phoneOrderSaveUser(params)
              if (res.data) {
                this.temp = { ...this.temp, ...res.data, csmAddressId: res.data.addressId }
                this.temp.csmId = res.data.csmId
                await this._setRelation(res.data.csmId)
                if (this.addressItems.length === 1) {
                  this.selectAddress(0, this.addressItems[0])
                }
              }
              if (res.success) {
                // this.searchCards()
                this.$message.success('保存成功')
              }
              this.btnStatus = false
            })
            return
          }
          params.lon = this.AddressData.longitude.toFixed(6)
          params.lat = this.AddressData.latitude.toFixed(6)
          const res = await phoneOrderSaveUser(params)
          if (res.data) {
            this.temp = { ...this.temp, ...res.data, csmAddressId: res.data.addressId }
            this.temp.csmId = res.data.csmId
            await this._setRelation(res.data.csmId)
            if (this.addressItems.length === 1) {
              this.selectAddress(0, this.addressItems[0])
            }
          }
          if (res.success) {
            // this.searchCards()
            this.$message.success('保存成功')
          }
          this.btnStatus = false
        })
      },
      // 新保存客户保存时将电话和地址填进去
      async _setRelation(csmId) {
        const res = await phoneOrderSearchCms({ csmId, fromPlat: 4 })
        this.phoneData = res.data
        this.phoneItems = this.phoneData.phoneItems.filter(l => l.cpStatus !== -1)
        this.addressItems = this.phoneData.addressItems
        this.$nextTick(function() {
          // 初始化关联地址选择
          if (this.addressItems.length === 1) {
            this.selectAddress(0, this.addressItems[0])
          } else {
            this.selectAddress()
          }
          // 初始化关联电话选择
          var dataitem = this.phoneItems.find(l => l.csmPhone === this.phoneData.csmRgPhone)
          var index = this.phoneItems.findIndex(l => l.csmPhone === this.phoneData.csmRgPhone)
          this.selectPhoneIndex = index
          this.selectPhone(index, dataitem)
          if (this.TabsActiveName !== 'dingGou') { // 当前在的tabs调接口更新数据
            this.$refs[this.TabsActiveName].getData(this.temp.csmId)
          }
        })
      },
      // 选择关联电话联系人
      selectPhone(i, data) {
        for (var item of this.$refs.selectPhone.children) {
          item.style.backgroundColor = '#fff'
        }
        this.$refs.selectPhone.children[i].style.backgroundColor = 'rgba(1,153,159,0.4)'
        // this.contactData.contact = data.contact
        // this.contactData.csmPhone = data.csmPhone
        // this.contactData = { ...this.contactData }
        this.contactInfo = { ...data } // 联系人详细信息
      },
      // 删除关联电话
      delPhone(data, index) {
        const vm = this
        const params = {
          csmPhoneId: data.csmPhoneId,
          csmPhone: data.csmPhone,
          csmId: data.csmId
        }

        vm.$confirm('是否删除此关联电话?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(async() => {
            const res = await phoneOrderDelPhone(params)
            if (res.success) {
              this.phoneItems.splice(index, 1)
              this.phoneItems = [...this.phoneItems]
              // var index = this.phoneItems.findIndex(l => l.csmPhone === this.phoneData.csmRgPhone)
              // this.selectPhoneIndex = index
              var i = index + 1
              if (i >= this.phoneItems.length) {
                i = 0
              }
              var dataitem = this.phoneItems[i]
              this.selectPhone(i, dataitem)
              this.$message.success('删除成功')
            }
          })
          .catch((e) => {
            // this.$message.info('已取消删除操作')
          })
      },
      // 选择关联地址
      async selectAddress(i, data) {
        if (this.addressRadio === i) return
        this.btnStatus = true
        this.isShow = false
        if (!i && !data) { // 不选择地址时的状态   如果客户地址很多  默认不选择
          for (var item of this.$refs.selectAddress.children) {
            item.style.backgroundColor = '#fff'
          }
          this.AddressData = {
            address: [], csmAddress: '', csmFloor: 1
          }
          this.cascaderKey++
          return
        }
        this.addressRadio = i
        for (item of this.$refs.selectAddress.children) {
          item.style.backgroundColor = '#fff'
        }
        this.selectAddressFlag = true
        this.$refs.selectAddress.children[i].style.backgroundColor = 'rgba(1,153,159,0.4)'
        this.addressRows = JSON.parse(JSON.stringify(data)) // 当前选择的数据  做比较  下面的那个数据已经和输入框双向绑定了
        this.AddressData = JSON.parse(JSON.stringify(data))
        if (this.$store.getters.userInfo.scopeLevel !== 1) {
          // this.AddressData.orgSNNo = this.$store.getters.userInfo.orgSNNo
        }
        this.treeKey++
        this.tableData.data = []

        //  通知级联地址选择框回显
        if (this.cascaderSwitch) { // 流程配置省市区不隐藏时
          var list = [data.provinceCode, data.cityCode, data.countryCode, data.streetCode]
          list = list.filter(l => l * 1 !== 0)
          this.AddressData.address = [...list]
          this.cascaderKey++
        } else {
          this.AddressData.address = []
        }
        if (!this.AddressData.csmFloor || this.AddressData.csmFloor === '0') this.AddressData.csmFloor = 1
        // 保险相关信息进行回显
        if (this.insureSeting) {
          const { insureCode, insureEndDt, insureStartDt } = data
          this.$set(this.temp, 'insureCode', insureCode)
          // this.temp.insureCode = insureCode
          if (insureCode) {
            this.$set(this.temp, 'insurance', [insureStartDt, insureEndDt])
            // this.temp.insurance = [insureStartDt, insureEndDt]
            this.insureCodeFlag = false
          } else {
            this.$set(this.temp, 'insurance', [])
            this.insureCodeFlag = true
          }
        }
        this.submitForm.orgId = data.orgId
        this.submitForm.orgSNNo = data.orgSNNo

        // 获取首单
        const info = await getDepositOrderInfoApi({ csmId: this.temp.csmId })
        this.isDeliver = info.data.isDeliver
        if (info.data.ckOrgId) {
          this.submitForm.orgId = info.data.ckOrgId
          this.submitForm.orgSNNo = info.data.ckOrgSNNo
        }
        if (info.data && info.data.depositDetails && info.data.depositDetails.length > 0) {
          this.relatedDepositCode = info.data.depositCode
          this.isFirst = true
          this.firstDetails = info.data.depositDetails
        }
        if (info.data.isDeliver) {
          // 近配送企业
          const res = await getNearestStationInfoApi({ latitude: data.latitude, longitude: data.longitude })
          if (res.data) {
            this.submitForm.orgId = res.data.orgId
            this.submitForm.orgSNNo = res.data.orgSNNo
          }
        }
        const orgInfo = this.orgList.filter((item) => {
          return item.orgId === this.submitForm.orgId
        })
        console.log('orgInfo[0]', orgInfo[0])
        this.appointmentInfo = orgInfo.length ? orgInfo[0] : {}
        this.orgData = orgInfo.length ? orgInfo[0] : null

        // 客户机构数据更新
        this.saveOrgData()
        // orgflag  表示筛选过后的机构数据存在这个id （即机构能被选中）
        if (this.orgTreeDataReal instanceof Array) {
          var orgflag = treeToArray(this.orgTreeDataReal).find(l => l.orgSNNo === this.submitForm.orgSNNo)
        }
        if (orgflag) {
          this.orgId = this.submitForm.orgId // 责任机构查询处理人需要的id
          await this.search_OrgidList() // 责任机构处理人
        }

        // 查询客户租瓶信息
        await this.queryDepositOrder()
        // 下单时自动添加最后一次订购的商品
        if (data.csmAddressId) {
          if ((this.corpSettingData.sp1 >> 16 & 0x01)) {
            // 如果有上次订气信息，则自动添加商品
            // await this.searchLastOrder(data.csmAddressId)
          }
          await this.queryGoods()
          if (this.temp.csmId) await this.firstOrder()
          // 查询客户是否存在未审核的安检单
          // await this.searchCsmGasCheck(data.csmAddressId)
          if ((this.corpSettingData.sp3 >> 18 & 0x01)) {
            this.anjianInfo = 1
          } else {
            this.anjianInfo = 0
          }
        }
        // this.temp.csmId = data.csmId
        this.$nextTick(async() => {
          this.queryGasCheckSet() // 安全隐患
        })
        this.btnStatus = false
        this.gettimeList()
        if (this.$refs.tuiPing) {
          this.$refs.tuiPing.getAllGoods()
        }
      },
      // 删除关联地址
      delAddress(data, index) {
        const vm = this
        const params = {
          csmAddressId: data.csmAddressId,
          csmId: data.csmId
        }
        vm.$confirm('是否删除此关联地址?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(async() => {
            const res = await phoneOrderDelAddress(params)
            if (res.success) {
              this.addressItems.splice(index, 1)
              this.addressItems = [...this.addressItems]
              var i = index + 1
              if (i >= this.addressItems.length) {
                i = 0
              }
              var dataitem = this.addressItems[i]
              this.selectAddress(i, dataitem)
              this.$message.success('删除成功')
            }
          })
          .catch((e) => {
            // this.$message.info('已取消删除操作')
          })
      },
      // 折叠效果
      fold(refItem) {
        const classname = event.target.className
        const flag = classname.includes('bottom')
        if (flag) {
          event.target.className = 'el-icon-caret-top'
        } else {
          event.target.className = 'el-icon-caret-bottom'
        }

        if (refItem === 'car_main') {
          // 卡片折叠函数
          this.cradChange({ refItem, setHeight: '95px', padding: '10px 10px 10px 5px' })
        }
        // 最近三次订购记录
        if (refItem === 'order') {
          // 卡片折叠函数
          // this.cradChange({ refItem, setHeight: '115px', padding: '0px 10px 10px 2px' })
          this.cradChange({ refItem, setHeight: '165px', padding: '0' })
        }
        // 快捷查询
        if (refItem === 'shortcut') {
          // 卡片折叠函数
          this.cradChange({ refItem, setHeight: '95%', padding: '10px 10px 10px 5px' })
        }
      },
      // 卡片折叠函数
      cradChange(obj) {
        const { refItem, setHeight, padding } = obj
        var height = this.$refs[refItem].style.height
        if (height === '0px') {
          this.$refs[refItem].style.height = setHeight
          this.$refs[refItem].style.padding = padding
          if (refItem === 'order') {
            this.isDefaultSky = true
          }
          if (refItem === 'shortcut') {
            this.$refs[refItem].parentNode.parentNode.style.flex = '1'
          }
        } else {
          this.$refs[refItem].style.height = '0'
          this.$refs[refItem].style.padding = '0px'
          if (refItem === 'order') {
            this.isDefaultSky = false
          }
          if (refItem === 'shortcut') {
            this.$refs[refItem].parentNode.parentNode.style.flex = 'none'
          }
        }
      },
      // 查询客户是否存在未审核的安检单
      async searchCsmGasCheck(csmAddressId) {
        try {
          const res = await phoneOrderCsmGasCheck({ csmAddressId })
          this.anjianInfo = res.data
        } catch (e) {
          console.log(e)
        }
      },
      //
      // 快速查询
      async  fastSearch(flag) {
        // shortcutParams.cmsAddress
        //  <el-option label="客户电话" :value="1" />
        //       <el-option label="客户名称" :value="2" />
        //       <el-option label="客户编码" :value="3" />
        //       <el-option label="身份证" :value="4" />
        //       <el-option label="使用证" :value="5" />
        //       <el-option label="充值卡" :value="6" /> csmRgAddress
        this.radio1 = 0
        try {
          var paramInfo = {}
          var paramName
          if (this.shortcutParams.select === 1) {
            paramName = 'csmRgPhone'
          } else if (this.shortcutParams.select === 2) {
            paramName = 'csmName'
          } else if (this.shortcutParams.select === 3) {
            paramName = 'csmCode'
          } else if (this.shortcutParams.select === 4) {
            paramInfo.sfzh = (this.shortcutParams.csmPhone).trim()
            // paramName = 'csmCode'
          } else if (this.shortcutParams.select === 5) {
            paramInfo.cardType = 1
            paramInfo['cardNo'] = (this.shortcutParams.csmPhone).trim()
          } else if (this.shortcutParams.select === 6) {
            paramInfo.cardType = 2
            paramInfo['cardNo'] = (this.shortcutParams.csmPhone).trim()
          } else if (this.shortcutParams.select === 7) {
            paramName = 'openAccountPhone'
          }
          paramInfo[paramName] = (this.shortcutParams.csmPhone).trim()
          if (this.shortcutParams.cmsAddress) {
            paramInfo = {
              csmRgAddress: this.shortcutParams.cmsAddress
            }
          }
          // { csmRgPhone: this.phoneData.csmRgPhone }
          const res = await phoneOrderFastSearch(paramInfo)
          if (res.data.length > 0) {
            // this.cmsCodeData = res.data
            this.qkparams = await res.data.filter(item => item.csmRgPhone)
            if (!flag) {
              this.radio1 = await this.qkparams.findIndex(l => l.csmId === this.phoneData.csmId)
            }
            const recheck = await recheckbillCheck({ csmid: this.qkparams[this.radio1]['csmId'] })
            this.recheckbill = false
            if (recheck.data && recheck.data > 0) {
              this.recheckbill = true
            }
            const res1 = await queryInfoPhone({ csmId: this.qkparams[this.radio1]['csmId'], phone: this.serach_phone })
            this.temp.qrCode = res1.data.qrCode
            this.cinfo = res1.data
            this.monthlyBillEndDt = res1.data.monthlyBillEndDt
          } else {
            this.$message.warning('未查找到客户信息')
          }
        } catch (e) {
          console.log(e)
        }
        // this.qkparams = qkparams.data
        if (flag && this.radio1 >= 0) {
          this.searchForPhone(false, this.qkparams[this.radio1]['csmId'])
          if (!this.serach_phone) return
          this.contactInfo.csmPhone = this.serach_phone
        }
      },
      // 快捷查询的单选事件
      changeRadio(val) {
        for (var item of this.$refs.checkRadio.children) {
          item.style.backgroundColor = '#fff'
        }
        this.$refs.checkRadio.children[val].style.backgroundColor = 'rgba(1,153,159,0.2)'
        this.searchForPhone(false, this.qkparams[val]['csmId'])
      },
      changeRadioL() {
        this.isLog = true
        // this.goodsTypesDetailList = []
        // this.orderForm.goodsId = undefined
        // this.orderForm.gtId = undefined
      },
      trimEnd(c, str) {
        if (c == null || !c) {
          var rg = /s/
          var i = str.length
          while (rg.test(str.charAt(--i)));
          return str.slice(0, i + 1)
        } else {
          rg = new RegExp(c)
          i = str.length
          while (rg.test(str.charAt(--i)));
          return str.slice(0, i + 1)
        }
      },
      // 查询优惠价格
      // phoneOrderSearchspecialPrice
      async specialPrice(param) {
        if (this.cacheSPrice) {
          return
        }
        try {
          const rlt = await phoneOrderSearchspecialPrice({ gtSNNo: param })
          if (rlt.exc != null) { return }
          var list = rlt.data
          var cachekeys = {}
          for (var i = 0; i < list.length; i++) {
            var item = list[i]
            var snno = item.orgSNNo ? this.trimEnd('0', item.orgSNNo) : ''
            if (snno === '001' || !snno) { snno = '@' }
            var gtsnno = item.gtSNNo ? this.trimEnd('0', item.gtSNNo) : ''

            /** 商品编号/商品分类-订单来源-机构-客户类型**/
            // var key = String.format('{0}-{1}-{2}-{3}',
            //                         item.goodsCode ? item.goodsCode : gtsnno,
            //                         item.orderSource === 0 ? '@' : item.orderSource,
            //                         snno,
            //                         item.customerType === 0 ? '@' : item.customerType
            // )
            var key = `${item.goodsCode ? item.goodsCode : gtsnno}-${item.orderSource === 0 ? '@' : item.orderSource}-${snno}-${item.customerType === 0 ? '@' : item.customerType}`
            cachekeys[key] = item.price
          }

          this.cacheSPrice = cachekeys
        } catch (e) {
          console.log(e)
        }
      },
      /* 优惠价 寻key 函数*/
      sosoFn(rg) {
        var cachekeys = this.cacheSPrice
        for (var key in cachekeys) { if (new RegExp(rg).test(key)) { return key } }
        return undefined
      },
      /* 优惠价格 寻址 */
      calcSPrice(info) {
        var cachekeys = this.cacheSPrice

        if (!cachekeys || cachekeys.length === 0) { return 0 }

        var goodsCode = info.goodsCode
        var gtSNNo = this.trimEnd('0', info.gtSNNo)
        var fromflag = info.fromflag
        var customerType = info.customerType
        var orgSNNo = (!info.orgSNNo ? '001' : info.orgSNNo)
        var tempkey = '^' + goodsCode + '-'
        var b = this.sosoFn(tempkey)
        if (!b) {
          tempkey = '^' + gtSNNo + '-'
        }
        if (!b && !this.sosoFn(tempkey)) { return 0 }

        if (fromflag !== '@' && !this.sosoFn(tempkey + fromflag + '-')) {
          fromflag = '@'
        }
        tempkey += fromflag + '-'
        if (!b && !this.sosoFn(tempkey)) { return 0 } else { b = true }

        while (orgSNNo.length >= 3) {
          b = this.sosoFn(tempkey + orgSNNo + '-')
          if (b) {
            break
          }

          orgSNNo = orgSNNo.substring(0, orgSNNo.length - 3)
        }
        if (orgSNNo.length === 0) {
          orgSNNo = '@'; b = false
        }
        tempkey += orgSNNo + '-'
        if (!b && !this.sosoFn(tempkey)) {
          if (fromflag !== '@') {
            info.fromflag = '@'
            return this.calcSPrice(info)
          }
          return 0
        } else { b = true }

        if (!this.sosoFn(tempkey + customerType)) {
          customerType = '@'
        }
        tempkey += customerType
        b = this.sosoFn(tempkey)
        if (!b) { return 0 }
        console.log(cachekeys[b], 'achekeys[b]')
        return cachekeys[b]
      },
      // 获取主营商品价格
      async getGoodsPrices() {
        try {
          const res = await phoneOrderGoodsPrices()
          this.mainGoodsPrices = res.data
        } catch (e) {
          console.log(e)
        }
      },
      // 查询区域价格
      async GetAreaprice(params) {
        try {
          const res = await phoneOrderAreaprice(params)
          this.AreapriceList = res.data
        } catch (e) {
          console.log(e)
        }
      },
      // 查询商品服务费
      async GetServePrice(params) {
        try {
          const res = await phoneOrderServePrice(params)
          this.ServePriceList = res.data
        } catch (e) {
          console.log(e)
        }
      },
      // 查询商品楼层费
      async GetFloorfee(params) {
        try {
          const res = await phoneOrderFloorfee(params)
          this.FloorfeeList = res.data
        } catch (e) {
          console.log(e)
        }
      },
      calCost(rowdata) {
        if (!rowdata) { return }
        var toFloat = function(str) {
          if ((/^(-?\d+)(\.\d+)?$/).test(str)) {
            return parseFloat(str)
          }
          return 0
        }
        var toInt = function(str) {
          if ((/^-?\d+$/).test(str)) {
            return parseInt(str)
          }
          return 0
        }
        var toDecimal = function(str, p) {
          if (/^(-?\d+)(\.\d+)?$/.test(str)) {
            return parseFloat(str).toFixed(p || 2) * 1
          }
          return 0
        }

        var price = toFloat(rowdata.diff ? rowdata.definePrice : rowdata.gprinceNum)
        var gprefPrice = toFloat(rowdata.gprefPrice)
        if (gprefPrice > price) {
          // $dlh.toast.info("优惠价格不能比市价大");
          gprefPrice = price
        }
        var gcount = toInt(rowdata.gcount)
        var fee1 = 0; var fee2 = 0; var tip = 0
        if (!this.submitForm.checkList.isPickUp) {
          if (rowdata.userTip) {
            tip = rowdata.userTip
          } else {
            tip = toFloat(rowdata.tip1) * gcount
          }
          if (rowdata.userFee1) {
            fee1 = rowdata.userFee1
          } else {
            fee1 = toFloat(rowdata.yf) * gcount
          }
          if (rowdata.userFee2) {
            fee2 = rowdata.userFee2
          } else {
            if (rowdata.isSpeicalPriceFloor && !rowdata.newDiff) {
              var floors = this.AddressData.csmFloor || 1
              if (floors > 1) {
                if (this.maxFloor > 0) {
                  floors = Math.min(floors, this.maxFloor)
                }
                fee2 = ((floors - 1) * toFloat(rowdata.fee21))
                fee2 += rowdata.baseFloorFee
                fee2 *= gcount
              }
            } else {
              fee2 = rowdata.fee21 * gcount
            }
          }
        }
        rowdata.fee1 = toDecimal(fee1, 2).toFixed(2)
        rowdata.fee2 = toDecimal(fee2, 2).toFixed(2)
        rowdata.tip = toDecimal(tip, 2).toFixed(2)
        rowdata.gprefPrice = gprefPrice
        rowdata.treceivable = (parseFloat((price - gprefPrice) * gcount) + parseFloat(rowdata.tip * 1) + parseFloat(rowdata.fee1) + parseFloat(rowdata.fee2 * 1)).toFixed(2)
        // rowdata.requiredScore = toInt(rowdata.priceScore) * toInt(rowdata.gcount)
        return rowdata
      },
      sosoAreaPrice(datas, gdId) {
        // TODO
        var orgInfo = this.orgData
        if (!orgInfo) {
          return undefined
        }
        // var gdId = 0;
        var orgSNNo = orgInfo.orgSNNo

        var flag = false
        for (var i in datas) {
          var item = datas[i]
          if (item.goodsId !== gdId) {
            if (flag) {
              break
            }
            continue
          } else if (flag === false) {
            flag = true
          }
          if (new RegExp('^' + item.orgPNNo).test(orgSNNo)) {
            // TODO 跋的千山万水,原来伊人在这里
            return item
          }
        }
        /** 回望遥遥路途,伊人在哪里**/
        return undefined
      },
      distanceFormat(v) {
        if (!Number(v)) {
          return ''
        }
        var msg = (Number(v) / 1000 || 0).toFixed(2)
        return msg
      },
      // 添加商品
      async addGoods(params) {
        if (!this.selectAddressFlag) {
          this.$message.error('请选择关联地址')
          return
        }
        if (!this.orgData) {
          this.$message.error('请选择所属机构')
          return
        }
        this.feeval = 0
        this.distance = 0
        const param = {
          feejson: {
            orgid: this.orgData.orgId,
            csmAddressId: this.AddressData.csmAddressId,
            goodid: this.orderForm.goodsId,
            cmstype: this.temp.csmType,
            lat: this.temp.latitude,
            lng: this.temp.longitude
          }
        }
        const res = await feeQueryByGood(param)
        if (res.data) {
          this.feeval = res.data.fee
          this.distance = this.distanceFormat(res.data.distance)
        }
        if (res.exc) {
          this.$message.warning(res.exc)
          return
        }
        const vm = this
        // var context = this
        // var grid = this.goodsGrid
        // this.endEditing(grid)
        var goodsInfo, gtInfo
        if (params.goodsId) {
          goodsInfo = vm.goodsTypesDetailList.find(l => l.goodsId === params.goodsId)
          gtInfo = vm.goodsTreeData.find(l => l.gtId === params.gtId)
          // goodsInfo.deliveryFun = this.feeval
        } else {
          goodsInfo = vm.goodsTypesDetailList.find(l => l.goodsId === vm.orderForm.goodsId)
          gtInfo = vm.goodsTreeData.find(l => l.gtId === vm.orderForm.gtId)
          if (!this.orderForm.goodsId || !this.orderForm.gtId) {
            vm.$message.warning('请先选择商品')
            return
          }
        }
        if (this.orderForm.orderFlag === 2) {
          var rowdatas = this.tableDataScore.data
        } else {
          rowdatas = this.tableData.data
        }
        for (var i in rowdatas) {
          var item = rowdatas[i]
          if (item.goodsId === goodsInfo.goodsId) {
            if (this.orderForm.orderFlag === 2 && this.corpSettingData.exchangeBuyMax) {
              if (item.gcount >= this.corpSettingData.exchangeBuyMax) {
                return
              }
            }
            if (item.gcount >= 99999) {
              this.readOnly = true
              return
            } else {
              this.readOnly = false
            }
            this.$message.warning('此商品已存在 数量累加  1 ')
            item.gcount++
            delete item.userFee1
            delete item.userFee2
            await this.calCost(item)
            this.tableData.data = [...this.tableData.data]
            return
          }
        }

        var customerType = this.temp.csmType
        var baseprice0 = goodsInfo['price0'] || 0
        var baseprice = goodsInfo[('price' + customerType)] || baseprice0
        if (this.isBasePrice) {
          baseprice = baseprice0
        }

        // ///////////////
        // var baseprice0 = goodsInfo['price0'] || 0
        // var baseprice = goodsInfo[('price' + customerType)] || baseprice0
        // if (this.isBasePrice) {
        //   baseprice = baseprice0
        // }
        // var mainPriceData = vm.mainGoodsPrices.find(l => l.goodsId === goodsInfo.goodsId)
        // if (mainPriceData) {
        //   if (this.isBasePrice) {
        //     baseprice0 = mainPriceData[`price0`]
        //   } else {
        //     baseprice = mainPriceData['price' + customerType] || mainPriceData['price0']
        //   }
        // }
        // if (this.isBasePrice) {
        //   baseprice = baseprice0
        // }
        // // 如果mainPrice找不到價格  就在商品列表里找
        // if (!baseprice) {
        //   baseprice0 = goodsInfo['price0'] || 0
        //   baseprice = goodsInfo[('price' + customerType)] || baseprice0
        //   if (this.isBasePrice) {
        //     baseprice = baseprice0
        //   }
        // }
        // ///////////

        var gprefprice = 0
        if (this.orderForm.orderFlag === 1) {
          var paramInfo = {
            goodsCode: goodsInfo.goodsCode,
            gtSNNo: gtInfo.gtSNNo,
            fromflag: 1,
            orgSNNo: '',
            customerType: customerType
          }
          var orgInfo = this.orgData
          if (orgInfo && orgInfo.orgPNNo) {
            paramInfo.orgSNNo = orgInfo.orgPNNo
          }

          gprefprice = this.calcSPrice(paramInfo)
          // console.log(gprefprice, 'gprefprice')
        }
        var rowdata = { id: new Date().getTime(),
                        goodsName: goodsInfo.goodsName,
                        goodsId: goodsInfo.goodsId,
                        gprinceNum: baseprice,
                        tag: parseInt(baseprice * 100),
                        definePrice: 0,
                        diff: 0,
                        gcount: 1,
                        gprefPrice: gprefprice,
                        tip: goodsInfo.tip || 0,
                        fee1: goodsInfo.deliveryFun || 0,
                        fee2: goodsInfo.floorFun || 0,
                        baseFloorFee: goodsInfo.baseFloorFee || 0,
                        treceivable: 0,
                        gtId: gtInfo.gtId,
                        gtFlag: gtInfo.gtFlag,
                        priceScore: goodsInfo.requiredScore || 0,
                        requiredScore: goodsInfo.requiredScore || 0,
                        pricingMode: goodsInfo.pricingMode || 1,
                        specCode: goodsInfo.specCode || '',
                        specName: goodsInfo.specName || '',
                        storeCount: goodsInfo.storeCount || 0,
                        isSpeicalPriceFloor: goodsInfo.isSpeicalPriceFloor,
                        preferentialPrice2: goodsInfo.preferentialPrice2
        }

        if (gtInfo.gtFlag < 3 && !goodsInfo.diff) { // && this.isBasePrice == false
          // TODO 寻址 区域特价
          // var datas = $dlh.cache.getAreaPriceCache()
          await this.GetAreaprice()
          if (this.AreapriceList) {
            var areaItem = this.sosoAreaPrice(this.AreapriceList, goodsInfo.goodsId)
            if (areaItem) {
              if (this.isBasePrice) {
                rowdata.gprinceNum = areaItem['price0']
              } else {
                rowdata.gprinceNum = areaItem['price' + customerType] || areaItem['price0']
              }
            }
          }
          //   // 服务费
          // var serveItem = vm.ServePriceList.find(l => l.goodsId === goodsInfo.goodsId && l.orgPNNo === orgPNNo)
          var serveItem = this.sosoServicePrice(vm.ServePriceList, goodsInfo.goodsId)
          if (serveItem) {
            var index = Math.log(customerType || 1) / Math.log(2)
            index++
            var fee1 = serveItem['spFee' + index] || serveItem['spFee0']
            if (fee1 & 0x01 > 0) {
              rowdata.fee1 = (fee1 >> 1) * 0.01
            }
            var fee2 = serveItem['lpFee' + index] || serveItem['lpFee0']
            if (fee2 & 0x01 > 0) {
              rowdata.fee2 = (fee2 >> 1) * 0.01
            }

            var tip = serveItem['tpFee' + index] || serveItem['tpFee0']
            if (tip & 0x01 > 0) {
              rowdata.tip = (tip >> 1) * 0.01
            }

            rowdata.fee1 = rowdata.fee1.toFixed(2)
            rowdata.fee2 = rowdata.fee2.toFixed(2)
            rowdata.tip = rowdata.tip.toFixed(2)
          }
        }
        // 特价自定义上楼费不覆盖
        if (!goodsInfo.isSpeicalPriceFloor) {
          var floorDatas = vm.FloorfeeList
          if (floorDatas) {
            var floorFee = this.sosoFloorFee(floorDatas, goodsInfo.goodsId, customerType)
            rowdata.fee2 = floorFee
          } else {
            rowdata.fee2 = 0
          }
        }
        var toDecimal = function(str, p) {
          if (/^(-?\d+)(\.\d+)?$/.test(str)) {
            return parseFloat(str).toFixed(p || 2) * 1
          }
          return 0
        }
        rowdata.yf = rowdata.fee1 // 单个商品原始的配送费
        rowdata.fee21 = rowdata.fee2 // 单个商品原始的上楼费
        rowdata.tip1 = rowdata.tip // 单个商品原始的服务费
        rowdata.intSpare3 = 0
        if (goodsInfo.diff) {
          var definePrice = goodsInfo.definePrice || 0
          if (goodsInfo.diff === 1) {
            definePrice = Math.max(0, baseprice0 - definePrice)
          }
          rowdata.definePrice = toDecimal(definePrice, 2)
          rowdata.diff = goodsInfo.diff
          rowdata.intSpare3 |= 1
        }
        rowdata.newDiff = false
        if (goodsInfo.preferentialPrice2 >= 0) {
          // TODO 优惠套餐生效,特价失效
          rowdata.intSpare3 = 0
          rowdata.definePrice = goodsInfo.preferentialPrice2
          rowdata.diff = 2
          rowdata.newDiff = true
        }
        rowdata.gprince = goodsInfo.preferentialPrice2 && goodsInfo.preferentialPrice2 >= 0 ? goodsInfo.preferentialPrice2 : rowdata.diff ? rowdata.definePrice : rowdata.gprinceNum
        rowdata = vm.calCost(rowdata)
        if (vm.orderForm.orderFlag === 2) {
          vm.tableDataScore.data.push(rowdata)
          return '商品兑换'
        }

        // 说明流程配置开关 - 下单商品关联客户气瓶库存勾选
        if ((this.corpSettingData.sp4 >> 9 & 0x01) > 0 && !this.lastOrderDetail) {
          // 判断当前添加商品是否存在租瓶任务单中
          var isExistDeposit = false
          var depositOrderRows = this.depositOrderData
          if (depositOrderRows && depositOrderRows.length > 0) {
            for (var x = 0; x < depositOrderRows.length; x++) {
              if (depositOrderRows[x].specCode === rowdata.specCode) {
                isExistDeposit = true
                break
              }
            }
          }
          if (!isExistDeposit) {
            this.$confirm('客户未租用该瓶型,是否继续添加商品?', '提示', {
              confirmButtonText: '添加',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
              vm.tableData.data.push(rowdata)
              // 按单位计价的，自动勾选“需回执”
              if (goodsInfo.pricingMode === 2) {
                this.$set(this.submitForm.checkList, 'isRe', true)
              }
            }).catch((e) => {
            })
          } else {
            vm.tableData.data.push(rowdata)
            // 按单位计价的，自动勾选“需回执”
            if (goodsInfo.pricingMode === 2) {
              this.$set(this.submitForm.checkList, 'isRe', true)
            }
          }
        } else {
          vm.tableData.data.push(rowdata)
          // 按单位计价的，自动勾选“需回执”
          if (goodsInfo.pricingMode === 2) {
            this.$set(this.submitForm.checkList, 'isRe', true)
          }
        }
        this.btnStatus = true
        setTimeout(() => {
          this.btnStatus = false
        }, 1000)
      },
      sosoFloorFee(datas, gdId, csmType) {
        const vm = this
        var orgInfo = this.orgData
        const floor = vm.AddressData.csmFloor ? vm.AddressData.csmFloor : 1
        const $ = {
          isEmptyObject: function(a) {
            var b
            for (b in a) { return !1 }
            return !0
          }
        }
        const isMatch = function(r, s) {
          return new RegExp(r).test(s)
        }
        if (!orgInfo) {
          orgInfo = { orgSNNo: '001000000000000000000' }
        }
        var orgSNNo = orgInfo.orgSNNo

        var goods = false
        for (var i in datas) {
          var item = datas[i]
          if (item.goodsId === gdId) {
            goods = true
            break
          }
        }

        if (goods) {
          var matchArr = []
          for (i in datas) {
            item = datas[i]
            if (item.goodsId === gdId && isMatch('^' + item.orgPNNo, orgSNNo)) {
              matchArr.push(item)
            }
          }

          var length = 0
          var result = []
          for (var j in matchArr) {
            item = matchArr[j]
            if (item.orgPNNo.length > length) {
              length = item.orgPNNo.length
              result.length = 0
              result.push(item)
            } else if (item.orgPNNo.length === length) {
              result.push(item)
            }
          }

          var match = {}
          matchArr = []
          for (var k in result) {
            item = result[k]
            if (item.floorStart <= floor && item.floorEnd >= floor && item[('floorFee' + csmType)] >= 0) {
              matchArr.push(item)
            }
          }
          match = this.matchFloor(matchArr, floor)

          var arr = []
          if ($.isEmptyObject(match)) {
            for (i = 0; i < result.length; i++) {
              item = result[i]
              if (!(item.floorStart <= floor && item.floorEnd >= floor) && item[('floorFee' + csmType)] >= 0) {
                arr.push(item)
              }
            }
            match = this.matchFloor(arr, floor)
          }

          if ($.isEmptyObject(match)) {
            for (k in result) {
              item = result[k]
              if (item.floorStart <= floor && item.floorEnd >= floor && item['baseFee'] >= 0) {
                matchArr.push(item)
              }
            }
            match = this.matchFloor(matchArr, floor)
          }
          if ($.isEmptyObject(match)) {
            for (i = 0; i < result.length; i++) {
              item = result[i]
              if (!(item.floorStart <= floor && item.floorEnd >= floor) && item['baseFee'] >= 0) {
                arr.push(item)
              }
            }
            match = this.matchFloor(arr, floor)
          }
          if (match.mode === 1) {
            return Number((match[('floorFee' + csmType)] || (match.baseFee ? match.baseFee : 0)) + (match.floor - match.floorStart) * match.modeAmount).toFixed(2)
          } else if (match.mode === 2) {
            result = Number((match[('floorFee' + csmType)] || (match.baseFee ? match.baseFee : 0)) - (match.floor - match.floorStart) * match.modeAmount).toFixed(2)
            return result < 0 ? 0 : result
          } else {
            return Number(match[('floorFee' + csmType)] || (match.baseFee ? match.baseFee : 0)).toFixed(2)
          }
        }
        return undefined
      },
      sosoServicePrice(datas, gdId) {
        // TODO
        var orgInfo = this.orgData
        if (!orgInfo) {
          orgInfo = { orgSNNo: '001000000000000000000' }
        }
        var orgSNNo = orgInfo.orgSNNo

        var flag = false
        for (var i in datas) {
          var item = datas[i]
          if (item.goodsId !== gdId) {
            if (flag) {
              break
            }
            continue
          } else if (flag === false) {
            flag = true
          }
          if (new RegExp('^' + item.orgPNNo).test(orgSNNo)) {
            return item
          }
        }
        return undefined
      },
      matchFloor(arr, floor) {
        var match = {}
        for (var k in arr) {
          var item = arr[k]
          if (item.floorStart <= floor && floor <= item.floorEnd) {
            match = item
            match.floor = floor
            return match
          }
        }

        var max = 0
        for (k in arr) {
          item = arr[k]
          if (item.floorEnd < floor) {
            max++
          }
          if (max === arr.length) {
            match = arr[arr.length - 1]
            match.floor = match.floorEnd
            return match
          }
        }
        var min = 0
        for (k in arr) {
          item = arr[k]
          if (item.floorStart > floor) {
            min++
          }
          if (min === arr.length) {
            match = arr[0]
            match.floor = match.floorStart
            return match
          }
        }

        for (k in arr) {
          item = arr[k]
          if (item.floorStart > floor) {
            match = arr[k - 1]
            match.floor = match.floorEnd
            return match
          }
        }
        return match
      },
      // 查询处理人
      async search_OrgidList() {
        if (!this.orgId) {
          return
        }
        const params = {
          orgId: this.orgId,
          corpparm1: 1
        }
        const res = await searchOrgidList(params)
        this.userData = res.data
        var ownerData = res.data
        var sp1 = this.corpSettingData.sp1
        if (sp1 >> 4 & 0x01) { // 默认选中主管
          for (var index in ownerData) {
            var item = ownerData[index]
            if ((item.utype >> 2 & 0x01) > 0) {
              this.submitForm.ownerId = item.userId
              // context.getObj('cbo_order_owner').combobox('setValue', item.userId)
              return
            }
          }
        } else if (sp1 >> 9 & 0x01) { // 默认选中上次处理人
          var checkedAddress = this.AddressData
          if (checkedAddress && checkedAddress.orgId === params.orgId) {
            for (var i = 0; i < ownerData.length; i++) {
              item = ownerData[i]
              if (item.userId === checkedAddress.lastSenderId) {
                this.submitForm.ownerId = item.userId
                // context.getObj('cbo_order_owner').combobox('setValue', item.userId)
                return
              }
            }
          }
        }
        // this.submitForm = { ...this.submitForm }
      },
      // 获取预付卡信息
      async getCardInfo() {
        const res1 = await queryInfoPhone({ csmId: this.qkparams[this.radio1]['csmId'], phone: this.serach_phone, orgSNNo: this.submitForm.orgSNNo })
        this.cinfo = res1.data
      },

      // searchOrgidList
      // 销售人员
      openInsure() {
        this.$refs.insure.open()
      },
      // 接受子组件insure 的值
      changeSaleMan(val) {
        this.$set(this.temp, 'saleMan', val.name)
        this.$set(this.temp, 'saleManId', val.id)
      },
      // 合计
      getSummaries(param) {
        const { columns, data } = param
        const sums = []

        columns.forEach((column, index) => {
          if (index === 0) {
            sums[index] = '合计'
            return
          }
          const values = data.map(item => {
            if (column.property === 'gprinceNum' && item.isSpeicalPriceFloor) {
              return 0
            } else {
              return Number(item[column.property])
            }
          })
          if (!values.every(value => isNaN(value))) {
            sums[index] = values.reduce((prev, curr) => {
              const value = Number(curr)
              if (!isNaN(value)) {
                return accAdd(prev, curr)
              } else {
                return prev
              }
            }, 0)
            if (this.orderForm.orderFlag === 1) {
              sums[index] = sums[index].toFixed(2)
            }
          } else {
            sums[index] = ''
          }
        })
        return sums
      },
      // 应收
      goodsPrice(row) {
        if (row.definePrice) {
          var value = (row.definePrice * 1 - row.gprefPrice * 1) * row.gcount * 1 + row.fee1 * 1 + row.fee2 * 1 + row.tip * 1
        } else {
          value = (row.gprinceNum * 1 - row.gprefPrice * 1) * row.gcount * 1 + row.fee1 * 1 + row.fee2 * 1 + row.tip * 1
        }
        row.receivable = value.toFixed(2)
        return value.toFixed(2)
      },
      // 积分应收
      goodsScores(row) {
        const value = (row.priceScore * 1) * (row.gcount * 1)
        row.requiredScore = value.toFixed(2)
        return value
      },
      // 选择数量
      changeNum(row, index) {
        const value = event.target.value
        row.gcount = value
      },
      // 删除商品
      delGoods(index) {
        const vm = this
        vm.$confirm('是否将该商品移除列表?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
            if (this.orderForm.orderFlag === 2) {
              this.tableDataScore.data.splice(index, 1)
              this.tableDataScore.data = [...this.tableDataScore.data]
              return
            }
            this.tableData.data.splice(index, 1)
            this.tableData.data = [...this.tableData.data]
            // this.$message.success('删除成功')
          })
          .catch((e) => {
            // this.$message.info('已取消删除操作')
          })
      },
      // 查询客户租瓶信息
      async queryDepositOrder() {
        if (!this.orgData || !this.AddressData.orgSNNo) {
          return
        }
        const params = {
          csmId: this.temp.csmId, orgId: this.orgData.orgId
        }
        if (!this.temp.csmId) {
          return
        }
        const rlt = await searchCustomerdeposit(params)
        var data = rlt.data || []
        // 订单租瓶信息
        this.depositOrderData = data
      },
      // 获取商品分类树
      async getGoodsTreeData() {
        const res = await goodsTypeQueryList({})
        const data = res.data.map(item => ({
          label: item.gtName,
          ...item
        }))
        this.goodsTreeData = getTreeData(data)
        this.orderForm.orderFlag = 1
      },
      // 选择商品分类
      async selectTreeChange(value) {
        if (!this.submitForm.orgSNNo) {
          this.$message.warning('请选择客户所属机构')
          return ''
        }
        this.getGoodsTypeDetails(value.gtId)
      },
      // 获取商品分类详情
      async getGoodsTypeDetails(val, bool = true) {
        try {
          if (this.orderForm.orderFlag === 1) {
            const item = this.addressItems.find(l => l.csmId === this.phoneData.csmId)
            const params = {
              csmType: this.temp.csmType,
              csmId: this.temp.csmId,
              orgSNNo: this.temp.orgSNNo,
              gtId: this.orderForm.gtId,
              isCallCenter: true,
              csmAddressId: item.csmAddressId,
              fromPlat: 4
            }
            const res = await phoneOrderDefineprice(params)
            this.goodsTypesDetailList = res.data
            // var res = await goodsTypeDetail({ gtId: val })
            // if (!res.data.rows) return
            // this.goodsTypesDetailList = res.data.rows
            await this.queryGoods()
            this.goodsTypesDetailList = this.list
            setTimeout(() => {
              if (this.cmstop3.length > 0) {
                this.orderForm.goodsId = this.cmstop3[0].detailList[0].goodsId
              } else {
                this.orderForm.goodsId = this.goodsTypesDetailList[0].goodsId
              }
            })
          } else if (this.orderForm.orderFlag === 2) {
            const res = await phoneOrdersearchScore({ gtId: val, orgSNNo: this.AddressData.orgSNNo, csmType: this.temp.csmType })
            if (!res.data) return
            this.goodsTypesDetailList = res.data
            setTimeout(() => {
              if (this.cmstop3.length > 0) {
                this.orderForm.goodsId = this.cmstop3[0].detailList[0].goodsId
              } else {
                this.orderForm.goodsId = this.goodsTypesDetailList[0].goodsId
              }
            })
          }

          this.orderForm.goodsId = null
          // if (bool && this.goodsTypesDetailList.length > 0) this.orderForm.goodsId = this.goodsTypesDetailList[0].goodsId
        } catch (error) {
          console.log(error)
        }
        // console.log('temp12321', this.temp)
        if (this.temp.csmId) this.firstOrder()
      },
      async queryGoods() {
        const vm = this
        var gtInfo = vm.goodsTreeData.find(l => l.gtId === this.orderForm.gtId)
        var orgInfo = this.orgData
        if (!gtInfo) {
          return ''
        }
        this.specialPrice(gtInfo.gtSNNo)
        const fn = async function(rlt) {
          var orgInfo = vm.orgData
          if (!orgInfo) {
            return
          }
          const csmTypeScope = vm.temp.csmType * 1
          for (var i = rlt.data.length - 1; i >= 0; i--) {
            var item = rlt.data[i]
            if (!item.saleMode || (item.saleMode && item.saleMode === 0)) {
              rlt.data.splice(i, 1)
              continue
            }
            if (!item.csmType || (item.csmType && item.csmType === 0)) {
              rlt.data.splice(i, 1)
              continue
            }
            if (item.csmType && ((csmTypeScope & item.csmType) === 0)) {
              rlt.data.splice(i, 1)
              continue
            }
            if (item.orgIds) {
              var arr = item.orgIds.split(',')
              var index = arr.indexOf(orgInfo.orgId + '')
              if (index < 0) {
                rlt.data.splice(i, 1)
              }
            }
          }
          // if (rlt.data && rlt.data.length > 0) {
          //   vm.goodsTypesDetailList = rlt.data
          //   vm.orderForm.goodsId = rlt.data[0].goodsId
          //   // 如果有上次订气信息，则自动添加商品
          //   // vm.temp
          // } else {
          //   vm.goodsTypesDetailList = []
          // }
          if (rlt.data && rlt.data.length > 0) {
            // 如果有上次订气信息，则自动添加商品
            vm.goodsTypesDetailList = rlt.data
            // vm.orderForm.goodsId = rlt.data[0].goodsId
            // vm.$set(vm.orderForm, 'goodsId', rlt.data[0].goodsId)
            if (vm.temp.csmId && vm.lastOrderDetail) {
              if (rlt.data.find(l => l.goodsId === vm.lastOrderDetail.goodsId)) {
                // 如果选择列表中存在goodsId 添加
                vm.$set(vm.orderForm, 'goodsId', vm.lastOrderDetail.goodsId)
                for (var j = 0; j < rlt.data.length; j++) {
                  if (vm.lastOrderDetail.goodsId === rlt.data[j].goodsId) {
                    //  vm.$set(vm.orderForm, 'goodsId', vm.lastOrderDetail.goodsId)
                    vm.tableData.data = []
                    await vm.addGoods({})
                    vm.isShow = true
                    setTimeout(() => {
                      vm.isShow = false
                    }, 10000)
                    break
                  }
                }
              }
            }
          } else {
            vm.goodsTypesDetailList = []
            vm.$set(vm.orderForm, 'goodsId', '')
          }
          if (vm.lastOrderDetail) {
            // 使用一次即作废
            vm.lastOrderDetail = undefined
            // 查询租瓶的列表进行比较判断订购列表存在客户未租用的瓶型
            // 说明是获取上次订单商品;并且存在租瓶任务单详情
            if (vm.depositOrderData && vm.depositOrderData.length > 0) {
              // 存在订单商品不再租瓶中
              var depositOrderIsNotExist = true
              var gridRows = vm.tableData.data
              if (gridRows.length > 0) {
                for (var x = 0; x < gridRows.length; x++) {
                  depositOrderIsNotExist = true
                  for (var y = 0; y < vm.depositOrderData.length; y++) {
                    if (gridRows[x].specCode === vm.depositOrderData[y].specCode) {
                      depositOrderIsNotExist = false
                      break
                    }
                  }
                  // 说明订单列表存在商品不再租瓶单中
                  if (depositOrderIsNotExist) {
                    break
                  }
                }
                // 流程配置勾选-下单商品关联客户气瓶库存
                if (depositOrderIsNotExist && (vm.corpSettingData.sp4 >> 9 & 0x01) > 0) {
                  vm.$alert('注意：订购列表存在客户未租用的瓶型 !', '提示', {
                    confirmButtonText: '确定'
                  })
                }
              }
            } else {
              // 流程配置勾选-下单商品关联客户气瓶库存
              if ((vm.corpSettingData.sp4 >> 9 & 0x01) > 0) {
                vm.$alert('注意：订购列表存在客户未租用的瓶型 !', '提示', {
                  confirmButtonText: '确定'
                })
              }
            }
          }
        }
        if (this.temp && (this.temp.isCustomPrice || this.addressRows.preferentialPackageId > 0) && !this.isBasePrice) {
          if (!orgInfo) {
            this.$message.warning('请选择客户所属机构!')
            return
          }
          if (!this.AddressData || !this.AddressData.csmAddressId) {
            return
          }
          const params = {
            gtId: this.orderForm.gtId,
            csmId: this.temp.csmId,
            csmType: this.temp.csmType,
            orgSNNo: orgInfo.orgSNNo,
            isCallCenter: true,
            csmAddressId: this.AddressData.csmAddressId,
            fromPlat: 4
          }
          const res = await phoneOrderDefineprice(params)
          if (res.data) {
            vm.list = res.data
            fn({ data: vm.list })
          }
          return
        }
        if (gtInfo.gtFlag < 3 && this.mainGoodsPrices) {
          var cacheList = this.mainGoodsPrices
          vm.list = []
          for (var i = 0; i < cacheList.length; i++) {
            var item = cacheList[i]
            if (item.gtId === gtInfo.gtId) {
              vm.list.push(item)
            }
          }
          fn({ data: vm.list })
          return
        }
        if (!this.temp.csmId) {
          this.$message.warning('请先选择客户!')
          return
        }

        if (!orgInfo) {
          this.$message.warning('请先选择客户所属机构!')
          return
        }
        var orgSNNo = orgInfo.orgSNNo
        const param = {
          gtId: this.orderForm.gtId,
          orgSNNo: orgSNNo,
          csmType: this.temp.csmType
        }
        const result = await phoneOrderOtherPrice(param)
        if (result.exc != null) { return }
        vm.list = []
        vm.list = result.data
        fn({ data: vm.list })
      },
      handleEdit(row, $index) {
        this.$set(row, '_edit', true)
        this.readOnly = false
      },
      handleSave(row, $index) {
        // const reg = /^(-?\d+)(\.\d+)?$/
        // if (!reg.test(row.discount)) {
        //   this.$message.warning('权益数值只能为数值')
        //   return
        // }
        // if (!reg.test(row.disLimit)) {
        //   this.$message.warning('优惠上限只能为数值')
        //   return
        // }
        this.$set(row, '_edit', false)
        this.$set(this.tableData.data, $index, JSON.parse(JSON.stringify(row)))
      },
      // 编辑订单
      changeInput(row, column, value) {
        row[column.property] = value
        this.$nextTick(() => {
          this.tableData.data = [...this.tableData.data]
        })
        // var reg=/(?:^[1-9]([0-9]+)?(?:\.[0-9]{1,2})?$)|(?:^(?:0)$)|(?:^[0-9]\.[0-9](?:[0-9])?$)/
        // const reg = /^(-?\d+)(\.\d+)?$/
        // if (reg.test(value)) {
        //   row[column.property] = value
        //   // this.tableData.data = [...this.tableData.data]
        // } else {
        //   row[column.property] = value

        //   // row[column.property] = ''
        // }
      },
      // 编辑校验
      blurInput(row, column, value) {
        var reg = /(?:^[1-9]([0-9]+)?(?:\.[0-9]{1,2})?$)|(?:^(?:0)$)|(?:^[0-9]\.[0-9](?:[0-9])?$)/
        var flag = reg.test(row[column.property])
        if (!row[column.property]) {
          row[column.property] = 0
        }
        if (!flag && row[column.property]) {
          this.$message.warning(`${column.label}只能输入数字或小数，请重新输入`)
          row[column.property] = 0
        }
        switch (column.property) {
        case 'fee1':
          row.userFee1 = row[column.property]
          break
        case 'fee2':
          row.userFee2 = row[column.property]
          break
        case 'tip':
          row.userTip = row[column.property]
          break

        default:
          break
        }
      },
      gcountblurInput(row, column, value) {
        var reg = /^\+?[0-9]\d*$/
        var flag = reg.test(row[column.property])
        if (!row[column.property]) {
          row[column.property] = 0
        }
        if (!flag && row[column.property]) {
          this.$message.warning(`${column.label}只能输入数字，请重新输入`)
          row[column.property] = 0
          return
        }
        if (row[column.property] > 99999) {
          row[column.property] = 99999
        }
        var toFloat = function(str) {
          if ((/^(-?\d+)(\.\d+)?$/).test(str)) {
            return parseFloat(str)
          }
          return 0
        }
        var rowdata = row
        var gconut = row[column.property]
        if (rowdata.isSpeicalPriceFloor) {
          var floors = this.AddressData.csmFloor || 1
          if (floors > 1) {
            if (this.maxFloor > 0) {
              floors = Math.min(floors, this.maxFloor)
            }
            rowdata.fee2 = ((floors - 1) * toFloat(rowdata.fee21))
            rowdata.fee2 += rowdata.baseFloorFee
            rowdata.fee2 *= rowdata.gcount
          }
        } else {
          row.fee21 === undefined ? row.fee21 = 0 : ''
          rowdata.fee2 = (gconut * row.fee21).toFixed(2)
        }
        rowdata.fee1 = (gconut * row.yf).toFixed(2)
        rowdata.tip = (gconut * row.tip1).toFixed(2)
        delete rowdata.userFee1
        delete rowdata.userFee2
        delete rowdata.userTip
        this.$nextTick(() => {
          this.tableData.data = [...this.tableData.data]
        })
      },
      async changeFloor(e) {
        const value = e.target.value
        var reg = /^\+?[0-9]\d*$/
        if (reg.test(value)) {
          if (value > 99) {
            this.$set(this.AddressData, 'csmFloor', 99 * 1)
          }
        } else {
          this.$set(this.AddressData, 'csmFloor', 1 * 1)
        }
        if (Number(this.AddressData.csmFloor) === 0) this.AddressData.csmFloor = 1
        if (!this.tableData.data.length) return
        var detailList = this.tableData.data
        for (var i in detailList) {
          var item = detailList[i]
          if (!item.isSpeicalPriceFloor) {
            var floorDatas = this.FloorfeeList
            var customerType = this.temp.csmType
            if (floorDatas) {
              var floorFee = this.sosoFloorFee(floorDatas, item.goodsId, customerType)
              item.fee21 = floorFee
            } else {
              item.fee21 = 0
            }
          }
          await this.calCost(item)
          // this.goodsGrid.datagrid('refreshRow', i)
        }
        this.tableData.data = [...this.tableData.data]
      },
      async changeIsPickUp(val) {
        // var value = this.submitForm.checkList.isPickUp
        if (!this.tableData.data.length) return
        var detailList = this.tableData.data
        for (var i in detailList) {
          var item = detailList[i]
          if (!item.isSpeicalPriceFloor) {
            var floorDatas = this.FloorfeeList
            var customerType = this.temp.csmType
            if (floorDatas) {
              var floorFee = this.sosoFloorFee(floorDatas, item.goodsId, customerType)
              item.fee21 = floorFee
            } else {
              item.fee21 = 0
            }
          }
          await this.calCost(item)
          // this.goodsGrid.datagrid('refreshRow', i)
        }
        this.tableData.data = [...this.tableData.data]

        // this.tableData.data = [...this.tableData.data]
      },
      // 积分数量校验
      orderNumBlurInput(row, column, value) {
        var reg = /^\+?[0-9]\d*$/
        var flag = reg.test(row[column.property])
        if (!flag && row[column.property]) {
          this.$message.warning(`${column.label}只能输入数字，请重新输入`)
          row[column.property] = 0
          return
        }
        if (row[column.property] > this.corpSettingData.exchangeBuyMax) {
          row[column.property] = this.corpSettingData.exchangeBuyMax
          return
        }
      },
      async SubmitSelectOrgTreeChange(val) {
        this.orgId = val.orgId
        this.$set(this.submitForm, 'ownerId', null)
        await this.search_OrgidList()
      },
      async sumitOrderFn(params, tables, keep) {
        const vm = this
        if (tables && tables.length > 0) {
          const res = await phoneOrderSubmit({
            billJson: params,
            detailJson: tables,
            gasCheck: vm.submitForm.checkList.gasCheck ? 1 : 0,
            callCode: ''
          })
          if (res.success) {
            vm.$message.success('订单提交成功')
            vm.tableData.data = []
            vm.tableDataScore.data = []
            vm.getTimeClear()
            if (!keep) {
              vm.reset()
              this.serach_phone = ''
              // vm.closeTag()
            }
          }
        } else {
          vm.$message.warning('请添加商品')
        }
      },
      async confirmAutoChargeback() {
        return new Promise((resolve, reject) => {
          if (this.corpSettingData.sp6 >> 25 & 0x01) {
            this.$confirm(`订单${this.corpSettingData.orderReturnDay}天未签收，自动退单，是否继续下单？`, '提示', {
              confirmButtonText: '立即下单',
              cancelButtonText: '暂不下单',
              type: 'warning'
            }).then(() => {
              resolve()
            }).catch(() => {
              reject()
            })
          } else {
            resolve()
          }
        })
      },
      // 提交并继续
      async submitOrderKeep(keep = true) {
        this.readOnly = false
        this.submitLoading = true
        setTimeout(() => {
          this.submitLoading = false
        }, 1000)
        if (this.addressRadio === null && !this.temp.csmAddressId) return this.$message.error('请勾选关联地址')
        const vm = this
        if (!this.temp.csmId) {
          vm.$message.warning('请先保存客户')
          return
        }
        if (!this.orgData || !this.AddressData.orgSNNo) {
          vm.$message.warning('请选择所属机构')
          return
        }
        if (this.cascaderSwitch) {
          if ((!this.AddressData.address) || !this.AddressData.csmAddress) {
            vm.$message.warning('请填写省市区地址和详细地址')
            return
          }
        } else {
          if (!this.AddressData.csmAddress) {
            vm.$message.warning('请填写客户详细地址')
            return
          }
        }
        if ((this.corpSettingData.sp1 >> 30 & 0x01) > 0) {
          var reg = /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/
          if (!this.temp.sfzh) {
            this.$message.error('请输入身份证号!')
            return
          }

          if (this.temp.sfzh && !reg.test(this.temp.sfzh)) {
            this.$message.error('身份证号格式不正确')
            return
          }
        }
        if (this.orderForm.orderFlag === 1 && !this.tableData.data.length) {
          this.$message.error('请添加商品')
          return
        }
        if (this.orderForm.orderFlag === 2 && !this.tableDataScore.data.length) {
          this.$message.error('请添加商品')
          return
        }
        let cost = 0
        if (this.orderForm.orderFlag === 1) {
          await this.tableData.data.forEach(e => {
            cost += Number(e.receivable)
          })
        } else {
          await this.tableDataScore.data.forEach(e => {
            cost += Number(e.receivable)
          })
        }
        if (this.submitForm.paymentMethod === 16 && (cost > (this.cinfo.decimalSpare2 - this.cinfo.settlementUseMonery))) {
          this.$message.error('月结额度不足')
          return
        }
        // console.log('cardSurplus', this.cinfo.cardSurplus)
        // if (this.submitForm.paymentMethod === 256 && (cost > (this.cinfo.cardSurplus / 100))) {
        //   this.$message.error('预付卡额度不足')
        //   return
        // }
        const res = await recheckbillCheck({ csmid: this.temp.csmId })
        if (res.data) {
          if (res.data > 0) {
            this.$message.error('该用户存在隐患尚未整改,请立即复检核查。目前无法购气')
            return
          }
        }
        var goodmsg = ''
        if (this.tableData.data.length > 0) {
          for (let x = 0; x < this.tableData.data.length; x++) {
            var specCode = this.tableData.data[x].gcount + '###' + this.tableData.data[x].specCode
            goodmsg = goodmsg + specCode + ','
          }
        }
        const param = {
          csmid: this.temp.csmId,
          gooddesc: goodmsg,
          orgId: this.orgData.orgId
        }
        const res2 = await depositinfoCheck(param)
        if (res2.data) {
          var str = res2.data.split('-')
          for (var x = 0; x < this.tableData.data.length; x++) {
            if (this.tableData.data[x].specCode === str[0]) {
              this.$message.error(this.tableData.data[x].goodsName + str[1])
              return
            }
          }
        }
        // 预约时间
        // var intSpare6 = 0
        // var array = [this.submitForm.appointment, this.time0, this.time1]
        // var flag1 = array.every(l => Boolean(l) === true)
        // var flag2 = array.every(l => Boolean(l) === false)
        // if (!(flag1 || flag2)) {
        //   vm.$message.warning('如选择了预约时间,请完整填写预约时间')
        //   intSpare6 = 1
        //   return
        // }
        // var day = this.submitForm.appointment * 1 + 1
        // if (day && this.submitForm.time.length) { // 判断填写了预约时间
        //   var time1 = this.submitForm.time[0].getHours() * 60 * 60 * 1000 + this.submitForm.time[0].getMinutes() * 60 * 1000 + this.submitForm.time[0].getSeconds() * 1000
        //   var time2 = this.submitForm.time[1].getHours() * 60 * 60 * 1000 + this.submitForm.time[1].getMinutes() * 60 * 1000 + this.submitForm.time[1].getSeconds() * 1000
        //   var starTime = new Date(day + time1)
        //   var endTime = new Date(day + time2)
        //   // if (new Date() * 1 > starTime * 1) {
        //   //   vm.$message.warning('预约开始时间错误,请重新选择')
        //   //   return
        //   // }
        // }
        // 处理人
        // if (!this.submitForm.ownerId) {
        //  vm.$message.warning('请选择处理人')
        //  return
        // }
        var ownerData = {}
        if (this.submitForm.ownerId) {
          ownerData = vm.userData.find(l => l.userId === vm.submitForm.ownerId)
        }
        this.getAddressCascaderInfo()
        const params = {
          //         AddressData: {}, // 联系人地址信息
          // contactInfo: {}, // 联系人详细信息
          'fromPlat': 4,
          'csmId': this.temp.csmId || '',
          'csmCode': this.temp.csmCode || '',
          'csmName': this.temp.csmName || '',
          'csmPhone': this.contactInfo.csmPhone || '',
          'contactPhone': this.contactInfo.csmPhone || '',
          'isPickUp': this.submitForm.checkList.isPickUp ? 1 : 0,
          'contact': this.contactInfo.contact || '',
          'csmAddressId': this.AddressData.csmAddressId || '',
          'csmAddress': `${this.addressCascader.provinceName}${this.addressCascader.cityName}${this.addressCascader.countryName}${this.addressCascader.streetName}${this.AddressData.csmAddress}${this.AddressData.doorplate}(楼层:${this.AddressData.csmFloor ? this.AddressData.csmFloor : 1})`,
          'intSpare5': this.AddressData.csmFloor || 1, // 楼层
          'csmType': this.temp.csmType || '',
          'strSpare2': this.temp.sfzh || '',
          'insureEndDt': this.temp.insurance ? this.temp.insurance[1] : '',
          'saleMan': this.temp.saleMan || '',
          'dateTimeSpare2': this.AddressData.lastSCheckDt ? this.parseDate(this.temp.lastSCheckDt) : '',
          'lon': this.AddressData.longitude.toFixed(6),
          'lat': this.AddressData.latitude.toFixed(6),
          'orgId': this.orgData.orgId || '',
          'orgSNNo': this.orgData.orgSNNo || '',
          'orgName': this.orgData.orgName || '',
          'ownerId': ownerData.userId || '',
          'ownerCode': ownerData.userCode || '',
          'ownerName': ownerData.userName || '',
          'isUrgent': this.submitForm.checkList.isUrgent ? 1 : 0,
          'isInvoice': this.submitForm.checkList.isInvoice ? 1 : 0,
          'paymentMethod': this.submitForm.paymentMethod,
          'reStatus': this.submitForm.checkList.isRe ? 2 : 1,
          'intSpare1': this.submitForm.checkList.isZb ? 1 : 0,
          'remark': this.submitForm.remark,
          'orderFlag': vm.orderForm.orderFlag,
          'relatedDepositCode': this.relatedDepositCode || ''
        }
        for (var value in params) {
          if (!params[value]) {
            delete params[value]
          }
        }
        if ((this.appointmentInfo.sp1 >> 4 & 0x01) === 1) {
          if (!this.currentDayContent) {
            this.$message.error('请选择预约时间')
            return
          } else {
            params.appointmentDt = new Date(this.confirmedDayInfo.day + ' ' + this.confirmedDayInfo.time.startTime)
            params.dateTimeSpare1 = new Date(this.confirmedDayInfo.day + ' ' + this.confirmedDayInfo.time.endTime)
          }
        }
        await this.confirmAutoChargeback()
        if (this.TabsActiveName !== 'dingGou') return
        // this.$message.info('提交并继续')
        this.sumitOrderFn(params, this.orderForm.orderFlag === 1 ? this.tableData.data : this.tableDataScore.data, keep)
      },
      // 老平台的日期格式化
      parseDate(str) {
        if (/^([0-9]{2,4})-([0-9]{1,2})-([0-9]{1,2})T([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}).([0-9]{1,3})\+(0800)$/.test(str)) {
          return new Date(str)
        }
        str = String(str).replace(/-/g, '/').replace('Z', '').replace('T', ' ')
        if (str.indexOf('.') > 0) {
          var dd = str.split('.')
          var d = new Date(dd[0])
          d.setMilliseconds(dd[1])
          return d
        }
        return new Date(str)
      },
      // 提交订单
      submitOrder() {
        if (this.TabsActiveName !== 'dingGou') return
        // this.$message.info('提交订单')
        if (!this.orgData || !this.AddressData.orgSNNo || !this.submitForm.orgSNNo) {
          this.$message.warning('请选择责任机构')
          return
        }
        if (!this.temp.csmId) {
          this.$message.warning('请先保存客户')
          return
        }
        if (this.addressRadio === null) return this.$message.error('请勾选关联地址')
        this.submitOrderKeep(false)
      },
      // 注释内容为原平台 挂载在Date上的方法
      // add(interval, number) {
      //   var d = this
      //   var k = {
      //     'y': 'FullYear',
      //     'q': 'Month',
      //     'm': 'Month',
      //     'w': 'Date',
      //     'd': 'Date',
      //     'h': 'Hours',
      //     'n': 'Minutes',
      //     's': 'Seconds',
      //     'ms': 'MilliSeconds'
      //   }
      //   var n = {
      //     'q': 3,
      //     'w': 7
      //   }
      //   eval('d.set' + k[interval] + '(d.get' + k[interval] + '()+' + ((n[interval] || 1) * number) + ')')
      //   return d
      // },

      // addDay(number) {
      //   return this.add('d', number)
      // },

      // addMonth(number) {
      //   return this.add('m', number)
      // },

      // addYear(number) {
      //   return this.add('y', number)
      // },
      // 超期未安检有关（老平台）
      dateDiff(interval, dt1, dt2) {
        if (!dt1) {
          dt1 = new Date()
        }
        if (!dt2) {
          dt2 = new Date()
        }
        if (arguments.length < 2) {
          return 0
        }
        var objInterval = {
          'D': 1000 * 60 * 60 * 24,
          'H': 1000 * 60 * 60,
          'M': 1000 * 60,
          'S': 1000,
          'T': 1
        }
        interval = interval.toUpperCase()
        // return Math.round((dt2.getTime() - dt1.getTime()) / eval('objInterval.' + interval))
        return Math.round((dt2.getTime() - dt1.getTime()) / objInterval[interval])
      },
      oldparseDate(str) {
        if (/^([0-9]{2,4})-([0-9]{1,2})-([0-9]{1,2})T([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}).([0-9]{1,3})\+(0800)$/.test(str)) {
          return new Date(str)
        }
        str = String(str).replace(/-/g, '/').replace('Z', '').replace('T', ' ')
        if (str.indexOf('.') > 0) {
          var dd = str.split('.')
          var d = new Date(dd[0])
          d.setMilliseconds(dd[1])
          return d
        }
        return new Date(str)
      },
      queryGasCheckSet() {
        var lastSCheckDt = this.AddressData.LastSCheckDt || this.AddressData.lastSCheckDt || ''
        if (!lastSCheckDt) {
          this.checkDtStr = ''
          // return
        }
        this.checkDtStr = lastSCheckDt ? dayjs(lastSCheckDt).format('YY-MM-DD') + ' ' : ''
        // 是否超期未安检
        var overCheck = false
        var lastSCheckDt2
        if (lastSCheckDt) {
          lastSCheckDt2 = this.oldparseDate(lastSCheckDt)
        } else {
          lastSCheckDt2 = this.oldparseDate('1970-01-01')
        }
        switch (this.AddressData.limitDays) {
        case -365:
          overCheck = (new Date().getFullYear() - lastSCheckDt2.getFullYear()) >= 1
          break
        case -90:
          if (new Date().getFullYear() - lastSCheckDt2.getFullYear() >= 1) {
            overCheck = true
          } else {
            overCheck = (new Date().getMonth() - lastSCheckDt2.getMonth()) >= 3
          }
          break
        case -30:
          if (new Date().getFullYear() - lastSCheckDt2.getFullYear() >= 1) {
            overCheck = true
          } else {
            overCheck = (new Date().getMonth() - lastSCheckDt2.getMonth()) >= 1
          }
          break
        default:
          overCheck = this.dateDiff('D', lastSCheckDt2, new Date()) > this.AddressData.limitDays
          break
        }
        if (overCheck) {
          // 开关：超期未安检提醒
          if ((this.AddressData.gasCheckSetOption >> 1 & 0x01) > 0) {
            this.checkDtStr += '<span style="color: red;font-weight: bold;">&ensp;(超期未安检)</span>'
          }
        }
        // _this.plat == 1
        if (this.temp) {
          if (!overCheck) {
            // 距离下次安检剩{0}天
            var remainDays = 0
            switch (this.AddressData.limitDays) {
            case -365:
              // 第二年的第一天和今天的差值
              var d = new Date(lastSCheckDt2.getFullYear() + 1, 0, 1)
              remainDays = this.dateDiff('D', d, new Date())
              break
            case -90:
              // 下一季度的第一天和今天的差值
              var currentSeason = Math.ceil((lastSCheckDt2.getMonth() + 1) / 3)
              d = new Date(lastSCheckDt2.getFullYear(), lastSCheckDt2.getMonth(), 1)
              // d.addMonth(currentSeason * 3 - lastSCheckDt2.getMonth())
              d = new Date(d.setMonth(d.getMonth() + currentSeason * 3 - lastSCheckDt2.getMonth() || 0 * 1))
              remainDays = this.dateDiff('D', d, new Date())
              break
            case -30:
              // 下个月的第一天和今天的差值
              d = new Date(lastSCheckDt2.getFullYear(), lastSCheckDt2.getMonth() + 1, 1)
              remainDays = this.dateDiff('D', d, new Date())
              break
            default:
              // 两个日期之间的差值
              d = new Date(lastSCheckDt2)
              // d.addDay(this.AddressData.limitDays)
              d = new Date(d.setDate(d.getDate() + this.AddressData.limitDays || 0 * 1))
              // console.log(d, 'd')
              remainDays = this.dateDiff('D', d, new Date())
              break
            }
            this.checkDtStr += `距下次安检剩余<span style="color:red;">${Math.abs(remainDays) || 0}</span>天`
          }
          // 安检隐患
          if (this.AddressData.lastCheckWarnLevel) {
            // this.checkDtStr += ` <a href="#" style="color:red;text-decoration: underline;" onclick="javascript:{0}.current.showWarnLevelWin({1});return false;">${this.AddressData.lastCheckWarnLevel}</a>`
            // , this.AddressData.lastCheckId, _this.warnLevelObj[this.AddressData.lastCheckWarnLevel]
          }
        }
      },
      // 订单流转信息
      openFlow(row) {
        this.$refs.flow.open(row.orderCode)
      },
      // 除订单外流转信息
      openOhtersFlow(row, page) {
        this.$refs.OhtersFlow.open(row, page)
      },
      // 催单
      openUrge(temp) {
        this.toPressOrder(temp)
      },
      async toPressOrder(row) {
        const params = { orderCode: row.orderCode }
        const res = await orderbillCanUrge(params)
        if (res) {
          if (res.data === 1) {
            this.$message.warning('该场站本时间段不支持催单！')
          } else if (res.data === 2) {
            this.$message.warning('无法催单，请到达预约时间段后催单！')
          } else if (res.data === 3) {
            this.$message.warning('暂不可催单，请稍后再试！')
          } else {
            await this.$refs.urge.open(row)
            this.refresh()
          }
        }
      },
      // 点击修改
      async changeAppointmentDt(row) {
        await this.$refs.changeAppointmentDt.open(row, this.temp)
      },
      // 刷新三次购气记录
      refresh() {
        this.get3orderHistory()
      },
      // 退单
      async openBackOrder(row) {
        // await this.$refs.backOrder.open(row)
        const res = await queryOrderbillReturnParam({
          orderCode: row.orderCode,
          ownerId: row.ownerId
        })
        const showCheck = JSON.parse(res.data.showCheck)
        if (showCheck) await this.$refs.backOrderApply.open(res.data)
        else await this.$refs.backOrder.open(res.data)

        this.$refs.lbTable.fetch({ currentPage: 1 })
      },
      // tabs切换
      async handleClick(tab) {
        await this.setHight()
        this.addressRadio = null
        this.selectAddress()
        var name = tab.name
        if (name === 'dingGou') return
        if (name === 'tuiPing') {
          this.$set(this.submitForm, 'orgSNNo', this.cinfo.orgSNNo)
          this.$set(this.submitForm, 'ownerId', null)
        }
        this.$nextTick(() => {
          this.$refs[name].getData(this.temp.csmId)
        })

        // 退瓶去客户地址责任机构
        // if (name === 'tuiPing') {
        //   this.$set(this.submitForm, 'orgSNNo', this.AddressData.orgSNNo)
        //   this.$set(this.submitForm, 'orgId', this.AddressData.orgId)
        //   // 处理人、预约时间取订单责任机构
        //   this.orgId = this.submitForm.orgId // 责任机构查询处理人需要的id
        //   const orgInfo = await this.orgList.filter((item) => {
        //     return item.orgId === this.submitForm.orgId
        //   })
        //   this.appointmentInfo = orgInfo.length ? orgInfo[0] : {}
        //   this.$set(this.submitForm, 'ownerId', null)
        //   await this.search_OrgidList() // 责任机构处理人
        // }
      },
      //  报修提交
      async  submitOrderBaoXiu() {
        const vm = this

        if (!this.temp.csmId) {
          vm.$message.warning('请选择关联地址或保存客户')
          return
        }
        if (!this.AddressData.orgSNNo) {
          vm.$message.warning('请选择关联地址或保存客户')
          return
        }
        if (this.cascaderSwitch) {
          if ((!this.AddressData.address) || !this.AddressData.csmAddress) {
            vm.$message.warning('请填写省市区地址和详细地址')
            return
          }
        } else {
          if (!this.AddressData.csmAddress) {
            vm.$message.warning('请填写客户详细地址')
            return
          }
        }
        const flag = this.$refs.baoXiu.isExist
        if (flag && this.$refs.baoXiu.checkQuery.length) {
          if (!this.$refs.baoXiu.submit.checkList.length) {
            vm.$message.warning('请选择一个报修内容')
            return
          }
        } else if (flag && !this.$refs.baoXiu.checkQuery.length) {
          if (!this.$refs.baoXiu.submit.remark) return vm.$message.warning('请输入原因')
        } else if (!flag) {
          if (!this.$refs.baoXiu.submit.checkList.length) {
            vm.$message.warning('请选择一个报修内容')
            return
          }
        }
        // 预约时间
        var array = [this.submitForm.appointment, this.time0, this.time1]
        var flag1 = array.every(l => Boolean(l) === true)
        var flag2 = array.every(l => Boolean(l) === false)
        if (!(flag1 || flag2)) {
          vm.$message.warning('如选择了预约时间,请完整填写预约时间')
          return
        }
        var day = this.submitForm.appointment * 1 + 1
        if (day && this.submitForm.time) { // 判断填写了预约时间
          var time1 = this.submitForm.time[0].getHours() * 60 * 60 * 1000 + this.submitForm.time[0].getMinutes() * 60 * 1000 + this.submitForm.time[0].getSeconds() * 1000
          var time2 = this.submitForm.time[1].getHours() * 60 * 60 * 1000 + this.submitForm.time[1].getMinutes() * 60 * 1000 + this.submitForm.time[1].getSeconds() * 1000
          var starTime = new Date(day + time1)
          var endTime = new Date(day + time2)
          if (new Date() * 1 > starTime * 1) {
            vm.$message.warning('预约时间错误,请重新选择')
            return
          }
        }

        // 处理人
        // if (!this.submitForm.ownerId) {
        //  vm.$message.warning('请选择处理人')
        //  return
        // }
        var ownerData = {}
        if (this.submitForm.ownerId) {
          ownerData = vm.userData.find(l => l.userId === vm.submitForm.ownerId)
        }
        this.getAddressCascaderInfo()
        const params = {
          appointmentEndTime: starTime || '',
          appointmentStartTime: endTime || '',
          callPhone: this.serach_phone,
          contact: this.contactInfo.contact || '',
          contactAddress: `${this.addressCascader.provinceName}${this.addressCascader.countryName}${this.addressCascader.cityName}${this.addressCascader.streetName}${this.AddressData.csmAddress}`,
          contactAddressId: this.AddressData.csmAddressId,
          contactPhone: this.contactInfo.csmPhone || '',
          csmAddress: `${this.addressCascader.provinceName}${this.addressCascader.countryName}${this.addressCascader.cityName}${this.addressCascader.streetName}${this.AddressData.csmAddress}`,
          csmCode: this.temp.csmCode || '',
          csmId: this.temp.csmId,
          csmName: this.temp.csmName,
          csmOrgId: this.AddressData.orgId,
          csmOrgName: this.AddressData.orgName,
          csmOrgSNNo: this.AddressData.orgSNNo,
          dueTime: new Date(),
          orgId: this.orgList.find(l => l.orgSNNo === this.submitForm.orgSNNo).orgId,
          orgName: this.orgList.find(l => l.orgSNNo === this.submitForm.orgSNNo).orgName,
          orgSNNo: this.submitForm.orgSNNo,
          remark: this.$refs.baoXiu.sumitRemark,
          repairContent: this.$refs.baoXiu.submit.checkList.join(',') + `+${this.$refs.baoXiu.submit.remark}`,
          userCode: ownerData.userCode || '',
          userId: ownerData.userId || '',
          userName: ownerData.userName || ''
        }
        for (var value in params) {
          if (!params[value]) {
            delete params[value]
          }
        }
        try {
          const res = await phoneOrdersumitRepair({
            billJson: params,
            callCode: ''
          })
          if (res.success) {
            // vm.closeTag()
            vm.reset()
            this.serach_phone = ''
            vm.$message.success('提交报修成功')
          }
        } catch (e) {
          console.log(e)
        }
      },
      // 新退瓶提交
      submitOrderTuiPing2() {
        // if (!this.submitForm.ownerId) {
        //   this.$message.warning('请选择处理人')
        //   return
        // }
        if (this.$refs.tuiPing.multipleSelection.length === 0 && !this.$refs.tuiPing.form.checked) {
          this.$message.warning('请选择押金单号或勾选无押金单')
          return
        }
        if (this.$refs.tuiPing.goodsList.every(item => item.num === 0)) {
          this.$message.warning('退瓶数量不能为空')
          return
        }
        if (!this.$refs.tuiPing.form.bottleRefundFee) {
          this.$message.warning('请输入上门取瓶费')
          return
        }
        this.$refs.tuiPing.getDepositDetails()
        this.getAddressCascaderInfo()
        var ownerData = {}
        if (this.submitForm.ownerId) {
          ownerData = this.userData.find(l => l.userId === this.submitForm.ownerId)
        }
        const params = {
          description: this.$refs.tuiPing.form.description,
          corpSN: this.temp.corpSN,
          corpCode: this.temp.corpCode,
          csmCode: this.temp.csmCode || '',
          csmId: this.temp.csmId,
          csmName: this.temp.csmName,
          contact: this.contactInfo.contact || '',
          contactAddress: `${this.addressCascader.provinceName}${this.addressCascader.countryName}${this.addressCascader.cityName}${this.addressCascader.streetName}${this.AddressData.csmAddress}`,
          contactAddressId: this.AddressData.csmAddressId,
          contactPhone: this.contactInfo.csmPhone || '',
          orgId: this.orgList.find(l => l.orgSNNo === this.submitForm.orgSNNo).orgId,
          orgName: this.orgList.find(l => l.orgSNNo === this.submitForm.orgSNNo).orgName,
          orgSNNo: this.submitForm.orgSNNo,
          userId: ownerData.userId || '',
          userName: ownerData.userName || '',
          depositCodes: this.$refs.tuiPing.multipleSelection.length > 0 ? this.$refs.tuiPing.multipleSelection[0].depositCode : '',
          bottleRefundFee: this.$refs.tuiPing.form.bottleRefundFee,
          giveType: this.$refs.tuiPing.form.checked ? 2 : 1,
          formPlat: 4,
          depositDetails: this.$refs.tuiPing.depositDetails
        }
        givebackRgSave(params).then(res => {
          if (res.data) {
            this.$message.success('操作成功')
            this.reset()
            this.serach_phone = ''
            this.$refs.tuiPing.initData()
          }
        })
      },
      // 退瓶提交
      async submitOrderTuiPing() {
        const vm = this
        if (!this.temp.csmId) {
          vm.$message.warning('请先保存客户')
          return
        }
        const flag = this.$refs.tuiPing.isExist
        if (flag && this.$refs.tuiPing.checkQuery.length) {
          if (!this.$refs.tuiPing.submit.checkList.length && !this.$refs.tuiPing.submit.remark) {
            vm.$message.warning('请选择一个退瓶原因或输入内容')
            return
          }
        } else if (flag && !this.$refs.tuiPing.checkQuery.length) {
          if (!this.$refs.tuiPing.submit.remark) return vm.$message.warning('请输入原因')
        } else if (!flag) {
          if (!this.$refs.tuiPing.submit.checkList.length && !this.$refs.tuiPing.submit.remark) {
            vm.$message.warning('请选择一个报修内容或输入内容')
            return
          }
        }
        // 预约时间
        var array = [this.submitForm.appointment, this.time0, this.time1]
        var flag1 = array.every(l => Boolean(l) === true)
        var flag2 = array.every(l => Boolean(l) === false)
        if (!(flag1 || flag2)) {
          vm.$message.warning('如选择了预约时间,请完整填写预约时间')
          return
        }
        var day = this.submitForm.appointment * 1 + 1
        if (day && this.submitForm.time) { // 判断填写了预约时间
          var time1 = this.submitForm.time[0].getHours() * 60 * 60 * 1000 + this.submitForm.time[0].getMinutes() * 60 * 1000 + this.submitForm.time[0].getSeconds() * 1000
          var time2 = this.submitForm.time[1].getHours() * 60 * 60 * 1000 + this.submitForm.time[1].getMinutes() * 60 * 1000 + this.submitForm.time[1].getSeconds() * 1000
          var starTime = new Date(day + time1)
          var endTime = new Date(day + time2)
          if (new Date() * 1 > starTime * 1) {
            vm.$message.warning('预约时间错误,请重新选择')
            return
          }
        }
        // 处理人
        // if (!this.submitForm.ownerId) {
        //  vm.$message.warning('请选择处理人')
        //  return
        // }
        var ownerData = {}
        if (this.submitForm.ownerId) {
          ownerData = vm.userData.find(l => l.userId === vm.submitForm.ownerId)
        }
        this.getAddressCascaderInfo()
        const params = {
          appointmentEndTime: starTime || '',
          appointmentStartTime: endTime || '',
          callPhone: this.serach_phone,
          contact: this.contactInfo.contact || '',
          contactAddress: `${this.addressCascader.provinceName}${this.addressCascader.countryName}${this.addressCascader.cityName}${this.addressCascader.streetName}${this.AddressData.csmAddress}`,
          contactAddressId: this.AddressData.csmAddressId,
          contactPhone: this.contactInfo.csmPhone || '',
          csmAddress: `${this.addressCascader.provinceName}${this.addressCascader.countryName}${this.addressCascader.cityName}${this.addressCascader.streetName}${this.AddressData.csmAddress}`,
          csmCode: this.temp.csmCode || '',
          csmId: this.temp.csmId,
          csmName: this.temp.csmName,
          orgId: this.orgList.find(l => l.orgSNNo === this.submitForm.orgSNNo).orgId,
          orgName: this.orgList.find(l => l.orgSNNo === this.submitForm.orgSNNo).orgName,
          orgSNNo: this.submitForm.orgSNNo,
          dueTime: new Date(),
          remark: this.$refs.tuiPing.sumitRemark,
          description: this.$refs.tuiPing.submit.checkList + `+${this.$refs.tuiPing.submit.remark}`,
          userCode: ownerData.userCode || '',
          userId: ownerData.userId || '',
          userName: ownerData.userName || ''
        }
        for (var value in params) {
          if (!params[value]) {
            delete params[value]
          }
        }
        try {
          const res = await phoneOrdersumitGiveback({
            billJson: params,
            callCode: ''
          })
          if (res.success) {
            vm.$message.success('退瓶申请已提交')
            this.reset()
            this.serach_phone = ''
            // vm.closeTag()
            this.$refs.tuiPing.submit.checkList = []
            this.$refs.tuiPing.submit.remark = ''
            this.$refs.tuiPing.tableData.data = []
          }
        } catch (e) {
          console.log(e)
        }
      },
      //  投诉和其他咨询的提交
      async submitOrderOthers(refName, chineseName) {
        const vm = this
        if (!this.temp.csmId) {
          vm.$message.warning('请先保存客户')
          return
        }
        if (refName === 'qiTa') {
          if (!this.$refs.qiTa.submit.remark) {
            vm.$message.warning('请填写内容')
            return
          }
        } else {
          const flag = this.$refs.touSu.isExist
          if (flag && this.$refs.touSu.checkQuery.length) {
            if (!this.$refs.touSu.submit.checkList.length) {
              vm.$message.warning('请选择一个投诉内容')
              return
            }
          } else if (flag && !this.$refs.touSu.checkQuery.length) {
            if (!this.$refs.touSu.submit.remark) return vm.$message.warning('请输入原因')
          } else if (!flag) {
            if (!this.$refs.touSu.submit.checkList.length) {
              vm.$message.warning('请选择一个报修内容')
              return
            }
          }
        }
        // 处理人
        // if (!this.submitForm.ownerId) {
        //   vm.$message.warning('请选择处理人')
        //   return
        // }
        var ownerData = {}
        if (this.submitForm.ownerId) {
          ownerData = vm.userData.find(l => l.userId === vm.submitForm.ownerId)
        }
        this.getAddressCascaderInfo()
        const params = {
          callPhone: this.serach_phone,
          contact: this.contactInfo.contact || '',
          contactAddress: `${this.addressCascader.provinceName}${this.addressCascader.countryName}${this.addressCascader.cityName}${this.addressCascader.streetName}${this.AddressData.csmAddress}`,
          contactAddressId: this.AddressData.csmAddressId,
          contactPhone: this.contactInfo.csmPhone || '',
          csmAddress: `${this.addressCascader.provinceName}${this.addressCascader.countryName}${this.addressCascader.cityName}${this.addressCascader.streetName}${this.AddressData.csmAddress}`,
          csmCode: this.temp.csmCode || '',
          csmId: this.temp.csmId,
          csmName: this.temp.csmName,
          csmOrgId: this.AddressData.orgId,
          csmOrgName: this.AddressData.orgName,
          csmOrgSNNo: this.AddressData.orgSNNo,
          orgId: this.orgList.find(l => l.orgSNNo === this.submitForm.orgSNNo).orgId,
          orgName: this.orgList.find(l => l.orgSNNo === this.submitForm.orgSNNo).orgName,
          orgSNNo: this.submitForm.orgSNNo,
          dueTime: new Date(),
          remark: this.$refs[refName].sumitRemark,
          userCode: ownerData.userCode || '',
          userId: ownerData.userId || '',
          userName: ownerData.userName || '',
          csmPhone: this.temp.csmRgPhone
        }
        if (refName === 'touSu') {
          params.complainContent = this.$refs[refName].submit.checkList.join(',') + `+${this.$refs[refName].submit.remark}`
        } else if (refName === 'qiTa') {
          params.description = this.$refs[refName].submit.checkList.join(',') + `+${this.$refs[refName].submit.remark}`
        }
        for (var value in params) {
          if (!params[value]) {
            delete params[value]
          }
        }
        try {
          var data = { billJson: params, callCode: '' }
          if (refName === 'touSu') {
            var res = await phoneOrdersumitComplain(data)
          } else {
            res = await phoneOrdersumitOrderOther(data)
          }

          if (res.success) {
            this.reset()
            this.serach_phone = ''
            // vm.closeTag()
            vm.$message.success('已提交')
          }
        } catch (e) {
          console.log(e)
        }
      },
      // 关闭当前标签页  并跳转到首页
      closeTag() {
        this.$store.dispatch('tagsView/delTag', { ...this.$route, routeName: 'phoneOrder' })
        // this.$store.dispatch('tagsView/delTag', { ...this.$route, routeName: 'phoneOrder' }).then(({ visitedTags }) => {
        //   console.log(visitedTags)
        //   if (this.isActive({ ...this.$route, routeName: 'phoneOrder' })) {
        //     this.toLastView(visitedTags, { ...this.$route, routeName: 'phoneOrder' })
        //   }
        // })
        this.$router.push({ name: '首页' })
      },
      reset() {
        this.temp = {
          csmType: 1
        }
        this.cardList = []
        this.csmcodeFlag = false
        this.insureCodeFlag = true
        this.tableData.data = []
        this.addressItems = []
        this.phoneItems = []
        this.phoneData = {}
        this.cmsCodeData = {}
        this.cmstop3 = [] // 最近三次订购数据
        this.qkparams = [] // 结果信息栏数据
        this.AddressData = {} // 联系人地址信息
        this.contactInfo = {} // 联系人详细信息
        this.contactData = {} // 联系人电话和地址信息 存本地
        this.addressCascader = {} // 级联选择对象
        this.checkDtStr = '' // 安检提示信息
        this.anjianInfo = null // 安检勾选判断   来自后端
        this.cacheSPrice = ''
        this.addressRows = {} // 当前选择的地址数据
        this.shortcutParams = {
          select: this.radioChoose || 1,
          csmPhone: null
        }
        this.orderForm = {
          orderFlag: 1,
          goodsId: null
        }
        this.submitForm.ownerId = null
        this.submitForm.orgSNNo = ''
        this.$set(this.submitForm, 'appointment', '')
        this.$set(this.submitForm, 'time', '')
        this.isTrue = false
      },
      getTimeClear() {
        this.appointmentList = []
        // this.appointmentInfo = {}
        this.currentAppointment = []
        this.currentAppointmentIndex = 0
        this.currentDayInfo = {}
        this.confirmedDayInfo = {}
        this.timePartList = {}
        this.currentDayContent = ''
      },
      async showAppointment() {
        const { data } = await accountopeningQuery({ orgId: this.appointmentInfo.orgId })
        this.currentAppointment = []
        const date = moment(new Date())
        if (data.range === 0) {
          this.currentAppointment.push(parseTime(date.format(), '{y}-{m}-{d}'))
        } else if (data.range === 1) {
          this.currentAppointment.push(parseTime(date.format(), '{y}-{m}-{d}'), parseTime(date.add(1, 'days').format(), '{y}-{m}-{d}'))
        } else if (data.range === 2) {
          this.currentAppointment.push(parseTime(date.format(), '{y}-{m}-{d}'), parseTime(date.add(1, 'days').format(), '{y}-{m}-{d}'), parseTime(date.add(2, 'days').format(), '{y}-{m}-{d}'))
        }
        this.currentDayInfo.day = parseTime(new Date(), '{y}-{m}-{d}')
        await this.gettimeList()
        // this.getTimeClear()
        if (this.appointmentInfo && (this.appointmentInfo.sp1 >> 4 & 0x01) === 1) {
          this.appointmentHandle()
        }
        if (this.confirmedDayInfo && this.confirmedDayInfo.day) {
          this.currentDayInfo.day = this.confirmedDayInfo.day
          await this.gettimeList()
          const c_item = this.timePartList.appointmentTimeList.findIndex(item => item.startTime === this.confirmedDayInfo.time.startTime)
          if (c_item) {
            this.timePartList.appointmentTimeList[c_item].select = true
          } else {
            this.timePartList.appointmentTimeList[0].select = true
          }
          this.currentDayInfo.time = this.confirmedDayInfo.time
        }
        this.popoverVisible = !this.popoverVisible
      },

      clearAppointment() {
        this.popoverVisible = !this.popoverVisible
        this.showClear = false
      },
      async appointmentHandle() {
        // this.appointmentList = this.appointmentInfo.appointmentTimes ? splitArray(this.appointmentInfo.appointmentTimes, 3) : []
        if (this.appointmentList.length > 0) {
          this.currentAppointment = this.appointmentList[0]
        }
        this.currentAppointmentIndex = 0
        if (this.currentAppointment.length > 0) {
          this.currentDayInfo.day = this.currentAppointment[0]
          await this.gettimeList()
          if (this.timePartList.appointmentTimeList && this.timePartList.appointmentTimeList.length > 0) {
            for (let i = 0; i <= this.timePartList.appointmentTimeList.length; i++) {
              if (!(this.timePartList.appointmentTimeList[i] && this.timePartList.appointmentTimeList[i].isFull)) {
                this.timePartList.appointmentTimeList[i].select = true
                this.currentDayInfo.time = this.timePartList.appointmentTimeList[i]
                break
              }
            }
          } else {
            const tomorrow = this.currentAppointment[this.currentAppointmentIndex + 1]
            this.selectAppointment(tomorrow, this.currentAppointmentIndex + 1)
          }
        }
      },

      forward() {
        if (this.currentAppointmentIndex > 0) this.currentAppointmentIndex--
        this.currentAppointment = this.appointmentList[this.currentAppointmentIndex]
      },
      future() {
        if (this.currentAppointmentIndex < (this.appointmentList.length - 1)) this.currentAppointmentIndex++
        this.currentAppointment = this.appointmentList[this.currentAppointmentIndex]
      },
      // 选中天
      async selectAppointment(val, index) {
        this.currentAppointmentIndex = index
        this.currentDayInfo.day = val
        this.currentDayInfo.time = null
        this.timePartList.appointmentTimeList = []
        await this.gettimeList()
        if (this.timePartList.appointmentTimeList && this.timePartList.appointmentTimeList.length > 0) {
          for (let i = 0; i <= this.timePartList.appointmentTimeList.length; i++) {
            if (!(this.timePartList.appointmentTimeList[i] && this.timePartList.appointmentTimeList[i].isFull)) {
              if (this.timePartList.appointmentTimeList[i]) {
                this.timePartList.appointmentTimeList[i].select = true
                this.currentDayInfo.time = this.timePartList.appointmentTimeList[i]
              }
              break
            }
          }
        }
      },
      // 选中时间段
      selectTimePart(val, index) {
        if (val.isFull) {
          this.$message.warning('该时段已约满')
          return
        } else {
          const i = this.timePartList.appointmentTimeList.findIndex(item => item.select)
          if (i !== -1) {
            this.timePartList.appointmentTimeList[i].select = false
            this.timePartList.appointmentTimeList[index].select = true
            this.currentDayInfo.time = val
          }
        }
      },

      confirmed() {
        if (this.currentDayInfo.day && this.currentDayInfo.time) {
          this.currentDayContent = this.currentDayInfo.day + '  ' + this.currentDayInfo.time.startTime + '~' + this.currentDayInfo.time.endTime
          if (this.currentDayInfo.time.dateFlag === 1) {
            this.currentDayContent = this.currentDayInfo.day + '  ' + this.currentDayInfo.time.endTime + ' 前送达'
          }
          this.popoverVisible = false
          this.confirmedDayInfo = JSON.parse(JSON.stringify(this.currentDayInfo))
        } else {
          if (this.timePartList.appointmentTimeList.length === 0) {
            this.$message.warning('无可选时间段')
          } else {
            this.$message.warning('请选择时间段')
          }
        }
      },

      // 获取时间段
      async gettimeList() {
        if (!this.temp || !this.temp.csmId) {
          return
        }
        if (!this.submitForm || !this.submitForm.orgId) {
          return
        }
        const params = {
          customerInfo: this.temp,
          date: this.currentDayInfo.day || parseTime(new Date(), '{y}-{m}-{d}'),
          orgId: this.submitForm.orgId,
          csmId: this.temp.csmId
        }
        const res = await orderAppointment(params)
        if (res && res.data) {
          this.timePartList = res.data
          const that = this
          let appointmentTimeList = []
          if (res.data.appointmentTimeList && res.data.appointmentTimeList.length > 0) {
            appointmentTimeList = res.data.appointmentTimeList
          }
          that.timePartList.appointmentTimeList = appointmentTimeList
          if (res.data.appointmentTimeList) {
            res.data.appointmentTimeList.forEach((item, index) => {
              if (this.orderForm.orderFlag === 1) {
                that.tableData.data.forEach((ele, orderI) => {
                  item.appointmentList.forEach((e, idx) => {
                    if (e.goodsId === ele.goodsId) {
                      that.timePartList.appointmentTimeList[index].appointmentList[idx]['existAppointment'] = true
                    }
                    if (ele.goodsName.indexOf('15') > -1 && e.goodsId === ele.goodsId) {
                      item.idx = idx
                    }
                  })
                })
              }
              // else {
              //   that.tableDataScore.data.forEach((ele, orderI) => {
              //     item.appointmentList.forEach((e, idx) => {
              //       if (e.goodsId === ele.goodsId) {
              //         that.timePartList.appointmentTimeList[index].appointmentList[idx]['existAppointment'] = true
              //       }
              //       if (ele.goodsName.indexOf('15') > -1 && e.goodsId === ele.goodsId) {
              //         item.idx = idx
              //       }
              //     })
              //   })
              // }
            })

            that.timePartList.appointmentTimeList = that.timePartList.appointmentTimeList.map(item => ({
              ...item,
              select: false,
              leftCount: item.idx > -1 ? item.appointmentList[item.idx].leftCount : 0,
              isFull: item.appointmentList.some(item => item.existAppointment && item.status === 0)
            }))
            console.log(that.timePartList.appointmentTimeList, '-------------')
          }
        }
      },
      // 定位
      async location() {
        const res = await this.$refs.location.open(this.AddressData)
        // 处理详细地址
        this.AddressData.latitude = res.point.lat
        this.AddressData.longitude = res.point.lng
        // this.temp.address = res.address
        // this.AddressData.cityCode = this.temp.city
        // this.AddressData.contact = this.temp.contactName
        const params = { ...this.AddressData }
        const res2 = await confirmLonLat({ ...params })
        if (res2.status === 200) {
          this.$message.success('经纬度确认成功')
        }
      },
      getLoad() {
        console.log('i am load')
        this.addressInfo.page_num++
        this.$refs.suggestionInput.fetchSuggestions()
      },
      async queryAddressSearch(queryString, cb) {
        // if (!queryString.includes('村')) {
        //   this.$message.warning('详细地址需要包含村或者小区、公交地铁站附近，方便精确计算配送费')
        // }
        const { provinceName, cityName, countryName } = this.temp
        if (queryString !== this.slectAddress.address) {
          this.addressInfo.page_num = 0
        }
        if (
          queryString !== this.AddressData.address &&
          queryString !== this.slectAddress.address
        ) {
          this.clearAddressInfo()
        } else {
          if (
            queryString === this.AddressData.address &&
            provinceName === this.AddressData.provinceName &&
            cityName === this.AddressData.cityName &&
            countryName === this.AddressData.countryName
          ) {
            this.temp.latitude = this.AddressData.latitude
            this.temp.longitude = this.AddressData.longitude
          }
          if (
            queryString === this.slectAddress.address &&
            provinceName === this.slectAddress.provinceName &&
            cityName === this.slectAddress.cityName &&
            countryName === this.slectAddress.countryName
          ) {
            this.temp.latitude = this.temp.latitude
            this.temp.longitude = this.temp.longitude
          }
        }
        this.getAddressSuggestionList(cb)
      },
      // 输入建议
      async getAddressSuggestionList(cb) {
        const params = {
          page_num: this.addressInfo.page_num,
          page_size: this.addressInfo.page_size,
          queryString: (this.AddressData.provinceName || '') + (this.AddressData.cityName || '') + (this.AddressData.countryName || '') + this.AddressData.csmAddress,
          city: this.AddressData.cityName
        }
        const res = await getLocalSearch(params)
        if (res && res.results && res.results.length > 0) {
          let list = []
          list = res.results.map(item => ({
            value: item.name || '',
            location: item.location,
            address: item.address || '',
            adcode: item.adcode || '',
            province: item.province || '',
            city: item.city || '',
            area: item.area || ''
          }))
          if (this.temp.area && this.temp.countryName) {
            list = list.filter(item => (item.area && item.area.includes(this.temp.countryName)) || (item.area === ''))
          }
          if (cb) {
            this.suggestionList = list
            cb(this.suggestionList)
          } else {
            this.$nextTick(() => {
              if (params.page_num > 0) {
                this.suggestionList = this.suggestionList.concat(list)
                this.$refs.suggestionInput.suggestions = this.suggestionList
              }
            })
          }
        } else {
          if (cb) {
            this.$message.error('未匹配到正确地址信息，请重新输入详细地址')
            cb([])
          }
        }
      },
      // 地址模糊匹配
      handleSelect(item) {
        this.clearAddressInfo()
        const latAndLon = item.location
        if (latAndLon && latAndLon.lat && latAndLon.lng) {
          this.temp.latitude = latAndLon.lat
          this.temp.longitude = latAndLon.lng
          this.slectAddress = {
            provinceName: this.temp.provinceName,
            cityName: this.temp.cityName,
            countryName: this.temp.countryName,
            address: this.temp.address
          }
          if (this.temp.orgId) {
            // this.checkAddress()
          }
        }
      },
      clearAddressInfo() {

      },
      // 就近配送-首单限制
      async firstOrder() {
        // console.log(this.TabsActiveName === 'dingGou')
        // console.log((this.cinfo && this.cinfo.driverOrgId > 0 && this.TabsActiveName === 'dingGou'))
        // console.log((this.cinfo && this.cinfo.corpCode === '33742' && this.TabsActiveName === 'dingGou'))
        // console.log((this.cinfo && this.cinfo.driverOrgId > 0 && this.TabsActiveName === 'dingGou') || (this.cinfo && this.cinfo.corpCode === '33742' && this.TabsActiveName === 'dingGou'))

        if (this.firstDetails && this.firstDetails.length > 0) {
          this.$set(this.tableData, 'data', [])
          this.$set(this.tableDataScore, 'data', [])
          for (var i = 0; i < this.firstDetails.length; i++) {
            const detailItem = this.firstDetails[i]
            const specCode = detailItem.specCode
            const goodsCount = detailItem.goodsCount
            const goodsTypesDetailList = this.goodsTypesDetailList.filter(item => item.specCode === specCode)
            this.orderForm.goodsId = goodsTypesDetailList[0].goodsId
            this.orderForm.goodsCount = goodsCount
            await this.addGoods({})
            this.changeInput(this.tableData.data[i], { property: 'gcount' }, goodsCount)
            this.gcountblurInput(this.tableData.data[i], { property: 'gcount' })
          }

          //
        } else {
          this.isFirst = false
          this.orderForm.goodsCount = 0
        }
      }
      // dateDiff(interval, dt1, dt2) {
      //   if (!dt1) {
      //     dt1 = new Date()
      //   }
      //   if (!dt2) {
      //     dt2 = new Date()
      //   }
      //   if (arguments.length < 2) {
      //     return 0
      //   }
      //   var objInterval = {
      //     'D': 1000 * 60 * 60 * 24,
      //     'H': 1000 * 60 * 60,
      //     'M': 1000 * 60,
      //     'S': 1000,
      //     'T': 1
      //   }
      //   interval = interval.toUpperCase()
      //   // return Math.round((dt2.getTime() - dt1.getTime()) / eval('objInterval.' + interval))
      //   return Math.round((dt2.getTime() - dt1.getTime()) / objInterval[interval])
      // }
    }
  }
</script>

<style lang="scss" scoped>
.cardthree {
  /deep/ .el-card__body {
    height: 93% !important;
  }
}
.page {
  display: flex;
  flex-direction: column;
  width: 100%;
  // height: 100%;
  .main-container {
    flex: 1;
    display: flex;
    justify-content: space-between;
    // height: 100%;
    overflow: auto;
    .left {
      display: flex;
      flex-direction: column;
      width: 65%;
      height: 100%;
      .order-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        .order {
          flex: 1;
          margin: 10px 0;
          .tabs_content {
            height: 100%;
          }
        }
      }
    }
    .right {
      width: 34%;
      height: 100%;
    }
  }
  .footer-container {
    display: flex;
    padding: 10px 5px 0 5px;
    // background-color: #F5F7FA;
    // border: 1px solid rgb(229, 231, 242);
    .left {
      width: 70%;
      /deep/.el-checkbox__label {
        padding-left: 2px;
      }
      /deep/.el-checkbox {
        margin-right: 10px;
      }
    }
    .right_btns {
      display: flex;
      align-items: flex-end;
      width: 97%;
      flex-shrink: 0;
      flex-direction: row-reverse;
      margin-bottom: 10px;
    }
    .footer_form {
      display: flex;
      flex-wrap: wrap;
      & /deep/ .el-form-item {
        // width: 22%;
        .el-form-item__content > .el-select {
          width: 100%;
        }
      }
    }
  }
}
</style>
<style lang='scss' scoped>
/deep/ .el-tabs {
  height: 100%;
}
/deep/.fast-checkinput {
  margin-left: 5px;
  flex: 1;
}
.radio-choose {
  float: right;
  margin-left: 40px;
  font-size: 13px;
  color: #8492a6;
}
.main {
  // position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  // height: 100%;
  overflow: hidden;
  overflow-y: auto;
  background: #fff;
  box-sizing: border-box;
  flex-wrap: wrap;
  // .left {
  //   width: 65%;
  // }
  // .right {
  //   margin-left: 20px;
  //   flex: 1;
  // }
}
.main_one {
  display: flex;
  width: 100%;
  box-sizing: border-box;
  .left {
    width: 65%;
    .tabs_content {
      .el-tab-pane {
        height: 100%;
      }
      & /deep/ .el-tabs--border-card {
        box-shadow: 0 0 0 0;
      }
    }
  }
  .right {
    width: 35%;
    padding-left: 20px;
    box-sizing: border-box;
    .dataFormRight {
      & /deep/ .el-form-item {
        // width: 33%;
        // margin-bottom: 10px;
        .el-form-item__content > .el-select {
          width: 100%;
        }
        .el-input-group__append {
          color: #01999f;
          border: 1px solid #01999f;
          border-color: #01999f;
          .huoqu:hover {
            height: 30px;
            // background-color: #f00;
            border: 0 solid rgba(0, 0, 0, 0);
            // border-color:#01999f ;
          }
          .el-button.is-plain:focus,
          .el-button.is-plain:hover {
            background: rgba(0, 0, 0, 0);
            border-right: 1px solid rgba(0, 0, 0, 0);
            border-left: 1px solid rgba(0, 0, 0, 0);
          }
        }
      }
    }
  }
}
.moneyinfo {
  display: flex;
  width: 100%;
  margin-bottom: 10px;
  margin-left: 5px;
  font-size: 14px;
  line-height: 19px;
  color: #333;
  text-indent: 8px;
  flex-wrap: wrap;
  .moneyinfo-item {
    width: 25%;
    margin-bottom: 10px;
    font-weight: 700;
  }
  .moneyinfo-item2 {
    margin-bottom: 10px;
    font-weight: 700;
  }
  span {
    margin-right: 8px;
    color: #606266;
  }
  .moneyinfo-value {
    display: inline-block;
    min-width: 30px;
  }
}

.form {
  display: flex;
  flex-wrap: wrap;
  // justify-content: space-between;
  & /deep/ .el-form-item {
    width: 33.3%;
    margin-bottom: 10px;
    .el-form-item__content > .el-select {
      width: 100%;
    }
    .el-input-group__append {
      color: #01999f;
      border: 1px solid #01999f;
      border-color: #01999f;
      .huoqu:hover {
        height: 30px;
        // background-color: #f00;
        border: 0 solid rgba(0, 0, 0, 0);
        // border-color:#01999f ;
      }
      .el-button.is-plain:focus,
      .el-button.is-plain:hover {
        background: rgba(0, 0, 0, 0);
        border-right: 1px solid rgba(0, 0, 0, 0);
        border-left: 1px solid rgba(0, 0, 0, 0);
      }
    }
  }
  /deep/.el-form-item--small .el-form-item__label {
    text-align: left;
  }
}
.block {
  width: 100%;
}

.info-title {
  display: flex;
  align-items: center;
  margin-top: 10px;
  margin-bottom: 20px;
  .title-icon {
    display: inline-block;
    width: 4px;
    height: 18px;
    margin-right: 6px;
    background: $themeColor;
  }
  span {
    font-weight: 700;
    color: $themeColor;
  }
  .clearfix {
    font-size: 14px;
  }
}

/deep/ .el-card__body {
  // padding:5px 10px;
  padding: 0;
}
/deep/ .el-card__header {
  height: 34px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: bold;
  // padding: 0;
  line-height: 34px;
  color: #373A3C;
  background: #E5E7F2;
  border: 1px solid #ddd;
  box-sizing: border-box;
}
.text {
  display: flex;
  // border: 1px solid #dddddd;
  // border-top: 0px solid #dddddd;
  justify-content: space-between;
  padding-left: 10px;
  font-size: 14px;
  line-height: 27px;
  color: #373A3C;
}
.chit_card {
  width: 100%;
  margin-bottom: 10px;
  //   /deep/ .el-card__body {
  //   padding:5px 10px;
  // }
  // 保险信息样式
  .card_main1 {
    width: 100%;
    height: 95px;
    padding: 10px 10px 10px 5px;
    overflow: hidden;
    transition: all 0.3s;
  }
  // 最近三次订购记录样式
  .card_main {
    width: 100%;
    // min-height: 60px;
    max-height: 160px;
    padding: 0 10px 10px 5px;
    overflow: hidden;
    transition: all 0.3s;
  }
  // 快捷查询样式
  .card_main_shortcut {
    width: 100%;
    height: 95%;
    padding: 10px 10px 10px 5px;
    overflow: hidden;
    overflow-y: auto;
    border: 1px solid #EBEEF5;
    border-radius: 5px;
    transition: all 0.3s;
  }
  .midOrder {
    width: 100%;
    margin-left: 55px;
    font-family: Microsoft YaHei, Microsoft YaHei-Regular;
    font-size: 14px;
    font-weight: 400;
    line-height: 24px;
    color: #373a3c;
    text-align: left;
  }
}
.cardBox_order {
  // height: 165px;
  width: 100%;
  font-family: Microsoft YaHei, Microsoft YaHei-Regular;
  font-size: 14px;
  font-weight: 400;
  line-height: 24px;
  color: #373a3c;
  text-align: left;
}
.likeTables {
  display: flex;
  width: 100%;
  line-height: 25px;
  border-bottom: 1px solid #ddd;
  .one {
    width: 20%;
    text-align: center;
  }
  .two {
    width: 40%;
    text-align: center;
  }
  .three {
    width: 20%;
    text-align: center;
  }
  .four {
    width: 20%;
    text-align: center;
    white-space: nowrap;
  }
}
.shortcut {
  display: flex;
  font-family: Microsoft YaHei, Microsoft YaHei-Regular;
  // width: 289px;
  // height: 41px;
  font-size: 14px;
  font-weight: 400;
  line-height: 22px;
  color: #373a3c;
  text-align: left;
  border-bottom: 1px solid #ddd;
  .shortcut_left {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 10%;
    margin: 0;
    /deep/ .el-radio__label {
      display: none;
    }
  }
}
.fontItem {
  font-family: Microsoft YaHei, Microsoft YaHei-Regular;
  // margin:2px 10px
  font-size: 14px;
  font-weight: 400;
  color: #999;
  text-align: left;
  text-indent: 1em;
}
.tabs_content {
  /deep/ .el-tabs__content {
    max-height: 330px;
    padding: 15px 10px 0 0;
    overflow: hidden;
    &:hover {
      overflow: auto;
    }
  }
  /deep/ .el-tabs__nav-scroll {
    .el-tabs__item {
      height: 40px;
      padding: 4px 8px;
      line-height: 30px;
      box-sizing: border-box;
    }

    width: 50px;
  }
}
.tableOrder {
  margin-bottom: 10px;
  /deep/ .el-input__inner {
    padding: 0 8px;
  }
}
.footer {
  position: absolute;
  bottom: 0;
  // bottom: -5px;
  z-index: 999;
  display: flex;
  width: auto;
  // width: calc(100% - 246px);
  width: 100%;
  padding-bottom: 10px;
  background-color: #fff;
  // padding: 5px;
  box-shadow: 0 3px 6px 0 rgba(0, 0, 0, 0.16);
  box-sizing: border-box;
  .left {
    width: 70%;
    // flex: 1;
    /deep/.el-checkbox__label {
      padding-left: 2px;
    }
    /deep/.el-checkbox {
      margin-right: 10px;
    }
  }
  .right_btns {
    display: flex;
    align-items: center;
    width: 30%;
    flex-shrink: 0;
    flex-direction: row-reverse;
    // justify-content: space-around;
  }
  .footer_form {
    display: flex;
    flex-wrap: wrap;
    & /deep/ .el-form-item {
      width: 25%;
      .el-form-item__content > .el-select {
        width: 100%;
      }
    }
    // & /deep/ .el-form-item .yuyueriqi {
    //   width: 25%;
    // }
    // & /deep/ .el-form-item .yuyueshijian {
    //   width: 35%;
    // }
  }
}
.orderForm {
  display: flex;
}
.Setiing {
  float: right;
  font-size: 18px;
  color: #01999F;
  &:hover {
    color: #989fc1;
  }
}
// 列表无数据时显示样式
.boxSky {
  width: 100%;
  height: 95px;
  padding: 30px;
  font-size: 14px !important;
  line-height: 30px;
  color: #909399;
  text-align: center;
}
footer {
  padding: 5px;
  background-color: #F5F7FA !important;
  border-top: 1px solid rgb(229, 231, 242);
}
.moduletitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fastSearchstyle {
  /deep/ .el-input-group__prepend {
    background: #fff;
  }
}
.remarks {
  display: flex;
}
.tableHeader {
  background-color: #f00;
}
.cardtwo {
  .card_main {
    height: 160px;
    padding: 0;
  }
  /deep/ .el-table {
    .tableHeader {
      background: #fff !important;
    }
    .el-table__header th {
      padding: 0 !important;
      background: #fff !important;
    }
    .el-link {
      margin-right: 5px;
    }
  }
}
.callseting {
  // display: inline-block;
  // width: 334px;
  height: 21px;
  font-family: Microsoft YaHei, Microsoft YaHei-Regular;
  font-size: 16px;
  font-weight: 400;
  color: #000;
  text-align: left;
}
.appointment {
  position: relative;
  width: 650px;
  cursor: pointer;
  .appointment-row {
    display: flex;
    width: 100%;
    margin-right: 20px;
  }
  .timeContent {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    border-bottom: 1px solid #dcdfe6;
    .placeholder {
      color: #c0c4cc;
    }
    img {
      width: 24px;
      height: 24px;
    }
  }
  .appointment-warp {
    position: absolute;
    bottom: 30px;
    z-index: 9999;
    width: 380px;
    padding: 10px;
    transform: scale(0.9);
    h4 {
      margin: 0 0 8px 0;
      font-weight: 500;
      text-align: center;
      border-bottom: 1px solid #DCDFE6;
    }
    .appointment-left {
      display: flex;
      padding-bottom: 8px;
      border-bottom: 1px solid #DCDFE6;
    }
    .head {
      width: 100px;
      background-color: #d7d7d7;
      border-left: 1px solid #d7d7d7;
      div {
        padding: 10px 0;
        text-align: center;
        cursor: pointer;
        background-color: #d7d7d7;
        flex: 1;
        span {
          display: block;
          line-height: 20px;
        }
        &:hover {
          background: #EBEEF5;
        }
      }
      .appointment-select {
        color: $themeColor;
        background-color: white;
      }
      i {
        font-size: 24px;
      }
    }
    .content {
      flex: 1;
      min-height: 100px;
      .content-item {
        width: 100%;
        .time-item {
          display: flex;
          padding-left: 10px;
          &:hover {
            background: #EBEEF5;
          }
          p {
            min-width: 30px;
            text-align: center;
            cursor: pointer;
            span {
              display: block;
            }
            .dis {
              color: red;
            }
          }
          .time-count {
            display: flex;
            align-items: center;
            justify-content: flex-start;
            width: 200px;
            span:nth-child(1) {
              margin-right: 20px;
            }
          }
          .p-disabel-gray {
            span:nth-child(1) {
              color: #c0c4cc;
            }
          }
          .time-active {
            color: $themeColor;
            // background-color: rgba(19, 177, 177, 0.2);
          }
        }
      }
      .noAppointmentList {
        min-height: 162px;
        line-height: 162px;
        color: #c0c4cc;
        text-align: center;
      }
    }
    .foot {
      margin-top: 8px;
      text-align: right;
    }
  }
}

.address-autocomplete {
  li {
    padding: 7px;
    line-height: normal;
    .addr {
      font-size: 12px;
      color: #b4b4b4;
    }
  }
}
.el-icon-location-information {
  position: relative;
  left: -2px;
}
.client-content {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  margin-bottom: 10px;
  .client-row {
    display: flex;
    width: 33%;
    margin-bottom: 10px;
    .client-label {
      width: 80px;
    }
    .client-label2 {
      width: 115px;
    }
    .client-value {
      flex: 1;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .red {
      color: #F56C6C;
    }
  }
  .client-row2 {
    display: flex;
    width: 66%;
    margin-bottom: 10px;
    .client-label {
      width: 80px;
    }
    .client-value {
      flex: 1;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }
}
.client-box {
  width: 100%;
  margin-bottom: 10px;
  /deep/.el-card__body {
    padding: 20px 20px 0 20px;
  }
}
.link {
  color: #01999F;
  cursor: pointer;
}
</style>
